problems with variables in subs
Posted: Mon May 12, 2008 5:27 pm
I have a problem with variables in subs.
I dont know whats wrong here.
The following program should write a binary number in a label by clicking on button "1" or "2"
to get a binary number e.g. 1001101.
But it doesn`t work correctly!
Why ?
`=======================
`Begin Code
DIM myvalue as string
Myvalue = " "
object myform as form
Caption = "myprogram "
Width = 400
Height = 225
`Color = &h4F9D00
object label1 as label
Caption = "label1"
Left = 57
Top = 24
Width = 112
Transparent = 1
end object
object button1 as button
Caption = "0"
Left = 56
Top = 100
Width = 49
TabOrder = 4
onclick=add0
end object
object button2 as button
Caption = "1"
Left = 136
Top = 100
Width = 49
TabOrder = 4
onclick=add1
end object
end object
myform.showmodal
`===========================
`[Subprograms]
`===========================
Sub add0(myvalue as string)
myvalue = myvalue + "0"
label1.Caption = myvalue
end sub
Sub add1(myvalue as string)
myvalue = myvalue + "1"
label1.Caption = myvalue
end sub
`End Code
`==========================
I dont know whats wrong here.
The following program should write a binary number in a label by clicking on button "1" or "2"
to get a binary number e.g. 1001101.
But it doesn`t work correctly!
Why ?
`=======================
`Begin Code
DIM myvalue as string
Myvalue = " "
object myform as form
Caption = "myprogram "
Width = 400
Height = 225
`Color = &h4F9D00
object label1 as label
Caption = "label1"
Left = 57
Top = 24
Width = 112
Transparent = 1
end object
object button1 as button
Caption = "0"
Left = 56
Top = 100
Width = 49
TabOrder = 4
onclick=add0
end object
object button2 as button
Caption = "1"
Left = 136
Top = 100
Width = 49
TabOrder = 4
onclick=add1
end object
end object
myform.showmodal
`===========================
`[Subprograms]
`===========================
Sub add0(myvalue as string)
myvalue = myvalue + "0"
label1.Caption = myvalue
end sub
Sub add1(myvalue as string)
myvalue = myvalue + "1"
label1.Caption = myvalue
end sub
`End Code
`==========================