Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I can't get my check boxes to work. So far I have on check box called box1 and one button called total. code is as follows:

 

Dim box1 as Boolean

 

 

If box1 = true then

 

messagebox.show("hello I am true")

 

else if box1 = false then

messagebox.show("hello I am false")

 

End if

 

I don't know why this doesn't work. The message box always comes up as hello I am false it doesn't matter if the box is checked or not.

 

Why is this, and how do I correct it.

  • *Experts*
Posted

You simply create a boolean value and do not do anything to it. And by default booleans are false. If you want to see whether a checkbox is checked you can do it like this:

If checkbox1.Checked Then
      'it is checked
Else
      'its not checked
End If

Posted

so it would look like this:

 

dim checkbox1 as boolean

 

If checkbox1.checked then

 

messagebox.show("hi I am true")

 

else if checkbox1.unchecked then

 

messagebox.show("hi i am false")

 

End if

  • *Experts*
Posted

No. Change the name "checkbox1" to the name of your checkbox.

Simply calling a boolean variable like your check wont work, because there is no relation between them and there would a variable name conflict :).

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...