i m new in VB
just self-learning..
if i wanna build a menu..
however, somewhere is highlight and seems wrong..
please help..

ck_chick.Value = 0 <--- is it wrong?

Option Explicit
Private Sub Form_Load()
Print "1"
End Sub
Private Sub Command1_Click(Index As Integer)
Dim food1, food2, food3, food4
Dim drink As String
Dim egg As String
Dim subfood As String
Dim ck_chick As Integer
Dim ck_beef As Integer
Dim ck_pork As Integer
Dim ck_fish As Integer
ck_chick.Value = 0 
ck_beef.Value = 0
ck_pork.Value = 0
ck_fish.Value = 0
If ck_chick.Value = 1 Then food1 = "雞扒"
End If
If ck_beef.Value = 1 Then food2 = "牛扒"
End If
If ck_pork.Value = 1 Then food3 = "豬扒"
End If
If ck_fishValue = 1 Then food4 = "魚柳"
End If
If ck_chick.Value = 0 And ck_beef.Value = 0 _
And ck_pork.Value = 0 And ck_fish.Value = 0 _
Then MsgBox = "請選一款"
End If
End Sub
Private Sub Command2_Click(Index As Integer)
Form_Load
End Sub
Private Sub Command3_Click(Index As Integer)
Unload Me
End
End Sub
Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)
ck_check1.Value = 0
ck_check2.Value = 0
ck_check3.Value = 0
ck_check4.Value = 0
End Sub
Private Sub Frame2_DragDrop(Source As Control, X As Single, Y As Single)
opt_option1.Value = False
opt_option2.Value = False
opt_option3.Value = False
opt_option4.Value = False
End Sub
Private Sub Frame3_DragDrop(Source As Control, X As Single, Y As Single)
opt_option5.Value = False
opt_option6.Value = False
opt_option7.Value = False
End Sub
Private Sub Frame4_DragDrop(Source As Control, X As Single, Y As Single)
opt_option8.Value = False
opt_option9.Value = False
opt_option10.Value = False
End Sub

Recommended Answers

All 9 Replies

You don't need to add ".value" to assign values for integers. Example: "ck_chick = 0"

You Say Something SEEMS Wrong. Did You Get A Runtime Error ? If So, What Was It.

It's Been A While Since I Did Any VB, So Someone Will Correct Me If I'm Wrong.....

There's Nothing Wrong With ck_chick.Value = 0. Check Boxes, Radio Buttons And A Host Of Other Controls (If Not All !) Have A Default Field That VB Assumes. Most Of The Time It Is The .Value Field. If You Just Use ck_chick = 0 Or opt_option1 = False, Then This Is Fine.

And what do you mean by 'somewhere is highlight' ?

You Say Something SEEMS Wrong. Did You Get A Runtime Error ? If So, What Was It.

It's Been A While Since I Did Any VB, So Someone Will Correct Me If I'm Wrong.....

There's Nothing Wrong With ck_chick.Value = 0. Check Boxes, Radio Buttons And A Host Of Other Controls (If Not All !) Have A Default Field That VB Assumes. Most Of The Time It Is The .Value Field. If You Just Use ck_chick = 0 Or opt_option1 = False, Then This Is Fine.

ck_chick is an integer. An error appears when ".value" is added to assign a value to integers and others such.

And what do you mean by 'somewhere is highlight' ?

I think he means that the ck_chick.value = 0 is highligted when the error appears.

oops... thanks all!!

i have tried the above suggestion....
but i dunno why it does not work still....
there may be other incorrect configuration..?!...
it makes me wanna give up..

http://www.profsr.com/vb/vbless04.htm
I've followed this link, the tutorial online taught to add .value
actually, i tried to type the same as the tutorial sample..
"Private sub command1()" <---- this line are always highlight with yellow color..
should i add some declaration inside the ()?
or add "Dim chick as Integer" <--- after?

is there any better online tutorial about VB for the beginners??
i wanna first attempt to make a menu with several check boxes ..

^___^" thank you for paying attention on my post...

I see. What are food1, food2 etc? You did not specify what they are.

I just noticed you were using End in your code!!!
That is a bad programming habbit and goes against programming standards. Try not to use it.

WHY?
if my idea is that, when someone click the command3 button, exit the program. then how should i set it?

i m really a beginner in VB... thx a lot

Unload Me

End is just wrong according to programming standards.
If you use Unload Me and there is only one form open then it will close the project though.

Then i guess in the Form_Unload event of the form you could close all other forms by simply...

Unload Form2
Unload Form3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.