Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Visual Basic Programming


ghost's Avatar
0 0

Hi, i just installed Visual Basic 6 and i've began making a program, its sort of a code lock. For the confirm button i've done the IF code = code then label.caption = "Correct" bit, but now how do i do if it doesn't = code then label1.caption = incorrect


ghost's Avatar
0 0

k…

if you do this:

private sub command1_click() text1.text ="1" end sub

private sub command2_click() text1.text ="2" end sub

you shouldn't have that problem anymore,but i don't know how you are trying to get things done…i t hink,you're going about it more difficult then you should…

hope that helps…if not,feel free to contact me.

peace.:happy:


ghost's Avatar
0 0

Thank you, i've finished it now, i went for a label.caption & command2.caption type thing. Here is my entire code for anyone else interested:

    Dim CodeValue As Integer
  Private Sub Command1_Click()
    If Label1.Caption = "" Then
          Label1.Caption = Command1.Caption
     Else
          Label1.Caption = Label1.Caption & Command1.Caption
     End If
End Sub

  Private Sub Command10_Click()
    If Label1.Caption = "" Then
          Label1.Caption = Command10.Caption
     Else
          Label1.Caption = Label1.Caption & Command10.Caption
     End If
End Sub

  Private Sub Command11_Click()
    If Label1.Caption = "4130" Then
          Label1.Caption = "Correct"
     Else
          Label1.Caption = "Incorrect"
     End If
End Sub

Private Sub Command12_Click()
    Label1.Caption = ""
End Sub

  Private Sub Command2_Click()
    If Label1.Caption = "" Then
          Label1.Caption = Command2.Caption
     Else
          Label1.Caption = Label1.Caption & Command2.Caption
     End If
End Sub
  Private Sub Command3_Click()
    If Label1.Caption = "" Then
          Label1.Caption = Command3.Caption
     Else
          Label1.Caption = Label1.Caption & Command3.Caption
     End If
End Sub
  Private Sub Command4_Click()
    If Label1.Caption = "" Then
          Label1.Caption = Command4.Caption
     Else
          Label1.Caption = Label1.Caption & Command4.Caption
     End If
End Sub
  Private Sub Command5_Click()
    If Label1.Caption = "" Then
          Label1.Caption = Command5.Caption
     Else
          Label1.Caption = Label1.Caption & Command5.Caption
     End If
End Sub
  Private Sub Command6_Click()
    If Label1.Caption = "" Then
          Label1.Caption = Command6.Caption
     Else
          Label1.Caption = Label1.Caption & Command6.Caption
     End If
End Sub
  Private Sub Command7_Click()
    If Label1.Caption = "" Then
          Label1.Caption = Command7.Caption
     Else
          Label1.Caption = Label1.Caption & Command7.Caption
     End If
End Sub
  Private Sub Command8_Click()
    If Label1.Caption = "" Then
          Label1.Caption = Command8.Caption
     Else
          Label1.Caption = Label1.Caption & Command8.Caption
     End If
End Sub
  Private Sub Command9_Click()
    If Label1.Caption = "" Then
          Label1.Caption = Command9.Caption
     Else
          Label1.Caption = Label1.Caption & Command9.Caption
     End If
End Sub

Private Sub Form_Load()
Label1.Caption = ""
CodeValue = 0
Command1.Caption = 1
Command2.Caption = 2
Command3.Caption = 3
Command4.Caption = 4
Command5.Caption = 5
Command6.Caption = 6
Command7.Caption = 7
Command8.Caption = 8
Command9.Caption = 9
Command10.Caption = 0
Command11.Caption = "Confirm"
End Sub