visual basic help? [Archive] - ForumsHQ

Post Reply
Demonic
Posts: 0
Joined: Sat Aug 24, 2002 5:00 am

visual basic help? [Archive] - ForumsHQ

Post by Demonic »

Public Sub form_load()

If Label2.DataField = "0" Then

Label3.Caption = "no"

Else: Label3.Caption = "yes"

End If



If Label5.DataField = "0" Then

Label6.Caption = "1 Handed-Blunt"

End If

If Label5.DataField = "1" Then

Label6.Caption = "2 Handed-Blunt"

End If

If Label5.DataField = "2" Then

Label6.Caption = "1 Handed-Sharp"

End If

If Label5.DataField = "3" Then

Label6.Caption = "2 Handed-Sharp"

End If



End Sub



did i do something wrong here? i have my database linked, datafields are linked correctly. (i.e. when i select a certain field it is listed) but when i run the app., it doesnt show anything in the label*.caption on any of them. is my syntax wrong? i am a n00b so youll hafta excuse me if im retarded.



a little more info...

i have a simple form using an SSTab (3 tabs only) the first tab i have linked to the same database, different field, and it works right. the 2nd tab i have this part that i am trying to show different attributes from a the database.

this is an NMR exported database, and this particular field, the values are 0,1,2, and 3. i just want it to look at the datafield and based on the value given, display the correct output.



any help would be appreciated.
syntax53
Posts: 0
Joined: Wed Apr 03, 2002 6:00 am

Re: visual basic help? [Archive] - ForumsHQ

Post by syntax53 »

what is label2, label3, label5, and label6? on appearance i would have thought you would say "if label2.datafield = "0" then label2.caption = "no" (not like you have it where you are checking on lebel2 and then setting the caption on label3).



i'll need to know them to continue. but to just make this code look how it should:



(same code, just formated and made most efficient)



Private Sub Form_Load()



If Label2.DataField = "0" Then

Label3.Caption = "no"

Else

Label3.Caption = "yes"

End If



Select Case Label5.DataField

Case "0": Label6.Caption = "1 Handed-Blunt"

Case "1": Label6.Caption = "2 Handed-Blunt"

Case "2": Label6.Caption = "1 Handed-Sharp"

Case "3": Label6.Caption = "2 Handed-Sharp"

Case Else: Label6.Caption = Label5.DataField & " (unknown)"

End Select



End Sub
Post Reply

Return to “Programming, web design & Graphics”