0

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
5
Contributors
9
Replies
10
Views
10 Years
Discussion Span
Last Post by ~Paul~
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.

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.

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.

0

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...

0

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.

0

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

0
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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.