vb窗体,左边为不定项复选框,单击“下一学科”可将选中的学科逐一在学科textbox中显示,即循环一一显示。
窗体控件
程序代码
Dim a(5) As String
Private Sub Check1_Click(Index As Integer)
aaa = Form1.Check1(Index).Caption
Text1.Text = Left(aaa, 2)
Text2.Text = Right(aaa, 2)
End Sub
Private Sub Command1_Click()
For i = 0 To 4
If Form1.Check1(i).Value = 1 Then
a(num) = Form1.Check1(i).Caption
num = num + 1
End If
Next i
For i = 0 To 4
If Left(a(i), 2) = Text1.Text Then
num_d = i + 1
If num_d >= num Then num_d = 0
Text1.Text = Left(a(num_d), 2)
Text2.Text = Right(a(num_d), 2)
Exit For
End If
Next i
End Sub
你试试,我调试过应该可以
谢谢回答!很不错!不过我设计本实例的目的是可以作为外接数据库的交互录入窗口,即text1来源于左边的check,text2由用户输入;另外,你的代码有一点儿BUG,如果运行正常后,减少1个check的选择,单击command1会失效。
不过复选按钮请采用控件组!
Option Explicit
Private Sub Check1_Click(Index As Integer)
Dim i As Integer
For i = 0 To Check1.UBound - 1
If Check1(i).Value = 1 Then
Text1.Text = Check1(i).Caption
Exit For
End If
Next i
End Sub
Private Sub Command1_Click()
Dim i As Integer
Dim j As Integer
Dim TF1 As Boolean
Dim TF2 As Boolean
TF1 = False
TF2 = False
For i = 0 To Check1.UBound
If Text1.Text = Check1(i).Caption Then
TF1 = True
Exit For
End If
Next i
If i < Check1.UBound Then
For j = i + 1 To Check1.UBound
If Check1(j).Value = 1 Then
TF2 = True
Text1.Text = Check1(j).Caption
Exit For
End If
Next j
End If
If TF1 And Not TF2 Then
For i = 0 To Check1.UBound
If Check1(i).Value = 1 Then
Text1.Text = Check1(i).Caption
Exit For
End If
Next i
End If
End Sub
'复选框的控件名称使用默认值
Private Sub Command1_Click()
Static i%
i = i + 1
If i > 5 Then i = 1
Controls("Check" & i).Value = 1
If i > 1 Then Controls("Check" & i - 1).Value = 0
If i < 5 Then Controls("Check" & 5).Value = 0
Text1.Text = Controls("Check" & i).Caption
End Sub
谢谢回答!要求没有完全满足。注意要求:1。学科的选择是不定的,如可选3科也可能选4科;2。显示方式是一一循环出现在学科旁的文字框内。举例:这次我选的是语文、英语、化学,右边的学科文字框中显示“语文”,单击“下一学科”,就显示为“英语”,再单击,显示“化学”,再单击,又显示“语文”;如重新选择左边的复选框,则发生相应的变化。期待您的完善。如果私信,请598804123@QQ.com。谢谢!
http://zhidao.baidu.com/question/497406425.html
在你这个问题里提交回答失败^_^已经给你百度私信,邮箱也已经私信与你
如果觉得简练且符合要求就请采纳