Picture
 VB Tricks & Tips
 Strings
 Controls
 Files
 Links
Picture

Visitors:

Picture
 Controls

Code snippets about VB controls, such as lists, command buttons etc. are listed here:


Private Function AlreadyListed(listControl As Control, newItem As String) As Boolean
                                                     
  ' The AlreadyListed function checks an existing
  ' list to see if a potential new entry (newItem)
  ' is currently in the list or not. If the item
  ' is in the list, the function returns true; if
  ' not, false.
 
  Dim i As Integer
 
  AlreadyListed = False
 
  ' Go through the current list and
  ' search for a match.
  For i = 0 To listControl.ListCount - 1
    If UCase$(listControl.List(i)) = _
      UCase$(newItem) Then _
      AlreadyListed = True
  Next i
 
End Function  ' AlreadyListed


Private Sub cmdExit_Click()

  ' The cmdExit_Click procedure ends the program
  ' when the user clicks the Exit button.

  End
 
End Sub  ' cmdExit_Click


Private Sub ValidNumInput(textControl As Control)

  ' The ValidNumInput procedure tests for a
  ' valid numeric input value in a text box that
  ' has just lost the focus.

  If Val(textControl.Text) = 0 Then _
    textControl.Text = "" _
  Else _
    textControl.Text = Val(textControl.Text)
   
End Sub  ' ValidNumInput


Private Sub Form_KeyDown _
  (KeyCode As Integer, Shift As Integer)

  ' The Form_KeyDown procedure allows the user to
  ' scroll through a sequence of records by pressing
  ' the PgUp or PgDn keys on the keyboard.
 
  ' *** Note that the form's KeyPreview property
  '     is set to True to make this event possible.
 
  ' Code numbers for the
  ' PgDn and PgUp keys.
  Const PgDn = 34
  Const PgUp = 33
 
  ' If the user presses PgDn and the Next
  ' button is currently enabled, force a call
  ' to the cmdNext_Click event procedure.
  If KeyCode = PgDn _
    And cmdNext.Enabled = True _
      Then cmdNext_Click
 
  ' If the user presses PgUp and the Previous
  ' button is currently enabled, force a call
  ' to the cmdPrevious_Click event procedure.
  If KeyCode = PgUp _
    And cmdPrevious.Enabled = True _
      Then cmdPrevious_Click


End Sub  ' Form_KeyDown


Private Sub cmdPrint_Click()

  PrintForm
 
End Sub


[VB Tricks & Tips] [Strings] [Controls] [Files] [Links]

Author: John N. Kostaras       Last modification: 2 May 2002
URL: https://jnkvb.tripod.com/