I think there is a world market for maybe five computers.
- Thomas Watson, Chairman of IBM 1943
This example is of a veterinarian clinic to look up costs based on 2 letter code for procedure performed. Select case does all the work because the example codes are hard coded in the program, not retrieved from a database, ect. Click the picture to see what it should look like
See Full Size
Private Sub cmdClear_Click() 'Clears us with a clean slate txtCode.Text = "" lstProcedure.Clear txtCode.SetFocus End Sub Private Sub cmdExit_Click() 'Will terminate the program End End Sub Private Sub cmdLookup_Click() Dim intRes As Integer 'Will do all the work Select Case UCase(txtCode.Text) Case "TC" lstProcedure.AddItem ("Teeth Cleaning $50") Case "RV" lstProcedure.AddItem ("Rabies Vaccination $15") Case "OS" lstProcedure.AddItem ("Other Shots $5") Case "HW" lstProcedure.AddItem ("Heartworm Test $15") Case "FC" lstProcedure.AddItem ("Fecal Check $5") Case "OV" lstProcedure.AddItem ("Office Visit $15") Case Else intRes = MsgBox("The code entered was invalid.", vbCritical, "Invalid Entry") txtCode.SelStart = 0 txtCode.SelLength = 2 txtCode.SetFocus End Select lstProcedure.Visible = True End Sub Private Sub cmdPrint_Click() 'Will print the form on the screen cmdLookup.Visible = False cmdPrint.Visible = False cmdClear.Value = False cmdExit.Visible = False Print Form cmdLookup.Visible = True cmdPrint.Visible = True cmdClear.Visible = True cmdExit.Visible = True End Sub Private Sub Form_Load() 'Will center the form on the screen frmMain.Left = (Screen.Width - frmMain.Width) / 2 frmMain.Top = (Screen.Height - frmMain.Height) / 2 End Sub
No Comments for this page.
You Must be
Rating of 5 (
Login to Rate This Code
Login to Post a Comment
Read more by this author
RGB Color Fader
Cut and Paste
Combo Box Colors
"AllSyntax.com" Copyright © 2002-2019; All rights lefted, all lefts righted.