Hi all
im trying to get value of a constructed checkbox.checkstate value


For i = 1 To 19
Dim scheckBox As String = "checkBox" & i & ".checkstate"
dim int as integer = scheckBox '

Next
---------------------------------------------------------------
in foxpro:
-------------
int=&(scheckBox)

any ideas???
thanks

Hi
So youve created a load of new checkboxes on the fly and then you want to go through each one and check if it has been checked?

To see if a checkbox is checked in VB.net (and VB too) you need to do something like this:

IF MyCheckBox.Checked Then
  'i.e MyCheckBox.Checked = true
Else
  'Not checked i.e. MyCheckBox.Checked =False
End If

To parse through the checkboxes you are going to have to grab their parent object (e.g. Form or Groupbox etc) and use something like Findcontrol to find each one:

dim sCheckBox as String
dim iCheckBox as Checkbox
dim MyState as Boolean
for i = 1 to 9
 sCheckBox = "checkbox" &i
 iCheckbox = Form.FindControl(sCheckBox)
 if iCheckbox isnot nothing then
    MyState = iCheckbox.Checked
 end if  
next

thanks
but find control isnot a property of form

Hi,
You should parse through the forms control collection or alternatively if you put them in another container through that.

I'm sorry I was talking about findcontrol, I was just giving you a rough idea off the top of my head, I'll not bother next time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.