|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Control Names
I want to make a simple sub that changes the state of a check box similar to the code below:
Private Sub CheckTheBox(CurrentCheckBox As CheckBox) If CurrentCheckBox.Value = 1 Then CurrentCheckBox.Value = 0 Else CurrentCheckBox.Value = 1 End If End Sub However, the name of the checkbox to be checked is dynamic and I do not know it design time. However, I can can have a string variable containg the name of the checkbox to be checked. How can I feed this string variable to the sub so that it knows which checkbox to set? Thanks |
|
#2
|
|||
|
|||
|
hi...why dont you just pass the actual checkbvox to the sub
sub changeIt(byref chk as checkbox) if chk.value = 0 then chk.value = 1 else chk.value = 0 end if end sub should work fine...
__________________
i am cope. i drink coke. i am in hope.i am cope. i drink coke. i am in hope.i am cope. i drink coke. i am in hope. |
|
#3
|
|||
|
|||
|
I cannot pass the actual check box because I am not always sending a particular checkbox. I can only pass the name of the checkbox, not the checkbox itself. And the name of the checkbox is determined during run time. I know there is a function in Javascript that does something like I want to do. It's called EVAL. But I don't know if there's anything similar in VB.
|
|
#4
|
|||
|
|||
|
You should make an array of checkboxes indexing them, it's easier to find one of them and you know its name.
|
|
#5
|
|||
|
|||
|
I thought about that approach but I cannot use it. Each check box is related to an Access DB field having the same name. I cannot use numbers in the DB. There's number of check boxes each having a name corresponding to a field in the database.
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > Control Names |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|