我有一个包含 12 个组框的表单,每个组框都有 3 个单选按钮。我for loop
用来获取选中的单选按钮并获取单选按钮的值。我声明字符串和整数变量通过组框和单选按钮。我的问题是如何连接字符串变量和整数变量。示例代码:
Dim opt, opt1, opt2, opt3, opt4, opt5, opt6, opt7, opt8, opt9, opt10, opt11, opt12 As String
Dim grpboxcnt As Integer = 1
Dim rdbtncnt As Integer = 1
Dim xrdbtn As String
For Each grpbx As GroupBox In Me.Controls.OfType(Of GroupBox)()
For Each rdbtn As RadioButton In Me.Controls("GroupBox" & grpboxcnt).Controls.OfType(Of RadioButton)()
If rdbtn.Checked = True Then
If rdbtn.Text = "Yes" Then
opt & rdbtncnt = 1 '(i want to be like this way but it is an error and it is not the proper way, is there any way to concat string variable to integer variable?) if this is checked i want to concat the string(opt) and integer(rdbtncnt) example opt & rdbtncnt = 1 ;but it gives me error
ElseIf rdbtn.Text = "No" Then
opt & rdbtncnt = 0 '(i want to be like that but it is an error and it is not the proper way, is there any way to concat string variable to integer variable?) if this is checked then i want to concat the string(opt) and integer(rdbtncnt) example opt & rdbtncnt = 0 ;but it gives me error
ElseIf rdbtn.Text = "NA" Then
opt & rdbtncnt = 2 '(i want to be like that but it is an error and it is not the proper way, is there any way to concat string variable to integer variable?) if this is checked i want to concat the string(opt) and integer(rdbtncnt) example opt & rdbtncnt = 2 ;but it gives me error
End If
End If
Next
rdbtncnt += 1 'then rdbtncnt increment new set of radiobuttons will be looped
grpboxcnt += 1 'then grpboxcnt increment new name of groupbox will be looped
Next
sqlcommand.commandType = "UPDATE table1 SET radio1 = @opt1, radio2 = @opt2 , radio2 = @opt3 , etc... WHERE tableID = 1"
提前致谢!