Hello
my tables have a column type varchar(5)
value = 10100
on a form I created five checkbox control
corresponding to the value in column
if the value =1 checkbox= true
and vice versa, the value = 0 checkbox = false
how I can upload the data forms correctly
by any code to help.
thanks a lot

Make a loop form 1 to length of the text and create a dynamic checkBox and show on your form checked/unchecked.

Dim x  as integer

for i as integer= 1 to x.length

'do your codes here

loop

hope it can give you a way.

You can do

Dim val As String = "10010"

For i As Integer = 0 To 4
    Dim cbx As CheckBox = Me.Controls("CheckBox" & i)
    cbx.Checked = val.Substring(i - 1, 1) = "1"
Next

Just replace the Dim statement with the statements to retrieve the data from the database. I don't know if your problem is with separating the values or with getting the info from the database. If the latter then please give a little more detail about the database (table name, etc). A generic query would be

SELECT myfield FROM tablename
 WHERE someOtherField = `some value`

I presume you have some way to limit the number of records returned to just one.

below is a detailed image of the example
http://imagizer.imageshack.com/img661/5905/9WJi39.png
I have not any code to be reasonable
can you help me fix code

Dim ch As String = Nothing
                Dim vl As String = Nothing
                Dim kq As String = Nothing
                For i As Integer = 0 To tb.Rows.Count - 1
                    ch = tb.Rows(i).Item("other")
                    For Each vl In ch
                        kq = vl

                        For j As Integer = 1 To ch.Length
                            If j = 1 And kq = 1 Then
                                ckb1.Checked = True
                            else
                                ckb1.Checked = False
                            End If
                            If j = 2 And kq = 1 Then
                                ckb2.Checked = True
                            else
                                ckb2.Checked = False
                            End If
                            If j = 3 And kq = 1 Then
                                ckb3.Checked = True
                            else
                                ckb3.Checked = False
                            End If
                            If j = 4 And kq = 1 Then
                                ckb4.Checked = True
                            else
                                ckb4.Checked = False
                            End If
                        Next
                    Next
                Next

Posting here a sample example codes which could solve your problem

 Dim x As String = "10111"

        For i As Integer = 1 To x.Length
            For Each control As Control In Me.Controls
                If TypeOf control Is CheckBox Then
                    If control.Name = "CheckBox" & CStr(i) Then
                        Dim chb As CheckBox = CType(control, CheckBox)
                        chb.Checked = Val(Mid(x, i, 1))
                        Exit For
                    End If
                End If
            Next
        Next

Hope it can help you.

@Sanu - note that Me.Controls("CheckBox" & i) will directly reference the control (but it has to be cast to CheckBox first).

@fugio - you have two examples here that do what you seeem to be asking. If you don't understand something specific please ask instead of just posting code.

commented: Thanks for pointing out an unnecessary loop of controls. +6
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.