|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
command button problem
hi i am very beginner... i started vb just...i created a command button. and then changed its name(caption) to cmdRoy. then i double clicked on that and got the coding window. there i wrote
simply Private Sub Command2_Click() cmdRoy.Caption = " Click " End Sub then i run this program......but getting error " object required... run time error '424' ....i dont understand this error. how can i fix it. i am studying the tutorial from this site http://www.developer.com/net/vb/art...10926_1538771_4 i want to ask one more question.. i found use of uppercase and lowercase letters in the variable. is there any rule / syntax for that??? e.g frmTest.BackColor = vbGreen capital and small letter mixed!!!!!!.... how to remember this??? thanks
__________________
intelchip |
|
#2
|
||||
|
||||
|
OK.. to clarify a few points for you, the caption property of a command button or any other control on a form has nothing to do with the identification of that control, for that, you have to change the (Name) property at the top of the form. If you'll look at your sub-procedure heading, you'll notice that it's still called Command2_Click - this is because the name of your button is Command2. You are getting the error because you are trying to call the caption method of a button that doesn't exist (there is no button on your form called cmdRoy) To rectify this situation, change either the name of the command button in the properties window to cmdRoy, or change the reference in your procedure to Command2.
Second - case doesn't matter in VB. VB's intellisense takes care of case issues. It is not as picky as other OO languages like C++ and JAVA. You can test this by typing in the following declarations in a subprocedure in your program. Code:
'type exactly as you see it here. dim InTcOuNtEr as integer 'type this in all lowercase intcounter=0 You should notice that when you hit enter after the intcounter=0 that the case will change to that of the variable declaration. Good Luck
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
|
#3
|
||||
|
||||
|
as a side note - it is often considered to be good practice to dimension your variables with mixed case, such as
Code:
dim intMyInteger as integer This gives you a way to check your variable declarations as your typing - since after you type "intmyinteger" in lowercase and hit <ENTER>, VB6 will change it to the proper case of the variable declaration. |
|
#4
|
|||
|
|||
|
Hi,intelchip!It's a obvious mistake!
cmdboy doesn't exist in your form!It cause the error you get! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > command button problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|