RSS Forums RSS
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 1020 | Replies: 9
Reply
Join Date: May 2007
Posts: 3
Reputation: kinchesskin is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kinchesskin kinchesskin is offline Offline
Newbie Poster

where is wrong?

  #1  
May 22nd, 2007
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
 
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2007
Location: Pearl of the Orient Seas
Posts: 181
Reputation: scudzilla is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 3
scudzilla's Avatar
scudzilla scudzilla is offline Offline
Junior Poster

Re: where is wrong?

  #2  
May 22nd, 2007
You don't need to add ".value" to assign values for integers. Example: "ck_chick = 0"
There are 10 types of people: those who understand Binary and those who don't!
Reply With Quote  
Join Date: May 2007
Location: Warrington, England
Posts: 31
Reputation: SkinHead is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
SkinHead SkinHead is offline Offline
Light Poster

Re: where is wrong?

  #3  
May 23rd, 2007
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.
Reply With Quote  
Join Date: Jun 2005
Posts: 70
Reputation: w00dy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 2
w00dy w00dy is offline Offline
Junior Poster in Training

Re: where is wrong?

  #4  
May 23rd, 2007
And what do you mean by 'somewhere is highlight' ?
Reply With Quote  
Join Date: Mar 2007
Location: Pearl of the Orient Seas
Posts: 181
Reputation: scudzilla is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 3
scudzilla's Avatar
scudzilla scudzilla is offline Offline
Junior Poster

Re: where is wrong?

  #5  
May 23rd, 2007
Originally Posted by SkinHead View Post
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.

Originally Posted by w00dy View Post
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.
There are 10 types of people: those who understand Binary and those who don't!
Reply With Quote  
Join Date: May 2007
Posts: 3
Reputation: kinchesskin is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kinchesskin kinchesskin is offline Offline
Newbie Poster

Re: where is wrong?

  #6  
May 24th, 2007
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...
Reply With Quote  
Join Date: Mar 2007
Location: Pearl of the Orient Seas
Posts: 181
Reputation: scudzilla is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 3
scudzilla's Avatar
scudzilla scudzilla is offline Offline
Junior Poster

Re: where is wrong?

  #7  
May 24th, 2007
I see. What are food1, food2 etc? You did not specify what they are.
There are 10 types of people: those who understand Binary and those who don't!
Reply With Quote  
Join Date: May 2007
Posts: 31
Reputation: ~Paul~ is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
~Paul~ ~Paul~ is offline Offline
Light Poster

Re: where is wrong?

  #8  
May 25th, 2007
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.
Reply With Quote  
Join Date: May 2007
Posts: 3
Reputation: kinchesskin is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kinchesskin kinchesskin is offline Offline
Newbie Poster

Re: where is wrong?

  #9  
May 25th, 2007
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
Reply With Quote  
Join Date: May 2007
Posts: 31
Reputation: ~Paul~ is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
~Paul~ ~Paul~ is offline Offline
Light Poster

Re: where is wrong?

  #10  
May 25th, 2007
  1. 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...

  1. Unload Form2
  2. Unload Form3
Last edited by ~Paul~ : May 25th, 2007 at 4:26 am. Reason: fixed
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 1:24 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC