!https://i.stack.imgur.com/RYIGs.png
当前,如果满足条件,DDi和DDj将显示消息“请为Device1,2或3选择设备通道”,“请选择其他设备通道对于Device1、2或3“。我想说的是通道的实际名称,而不是Device1,Device2等。我不知道如何将数组放入现有结构中。我从下面开始,但是在for开头出现语法错误。
If (HTSelection.DeviceDropDown1.List(0)) <> Empty Then
Else
DeviceDropDown1.AddItem "Device A: HT 1"
DeviceDropDown1.AddItem "Device A: HT 2"
DeviceDropDown1.AddItem "Device A: HT 3"
DeviceDropDown1.AddItem "Device A: HT 4"
DeviceDropDown1.AddItem "Device A: HT 5"
DeviceDropDown1.AddItem "Device A: HT 6"
DeviceDropDown1.AddItem "Device A: HT 7"
DeviceDropDown1.AddItem "Device A: HT 8"
DeviceDropDown1.AddItem "Device B: HT 1"
DeviceDropDown1.AddItem "Device B: HT 2"
DeviceDropDown1.AddItem "Device B: HT 3"
DeviceDropDown1.AddItem "Device B: HT 4"
DeviceDropDown1.AddItem "Device B: HT 5"
DeviceDropDown1.AddItem "Device B: HT 6"
DeviceDropDown1.AddItem "Device B: HT 7"
DeviceDropDown1.AddItem "Device B: HT 8"
DeviceDropDown1.AddItem "Channel_Not_Available"
End If
End Sub
Private Sub HTNextButton_Click()
Dim DDi(1 To 3) As String
DDi(1) = "Temperature"
DDi(2) = "Adapter"
DDi(3) = "USB"
Dim i As Integer
Dim DDj(1 To 3) As String
DDj(1) = "Temperature"
DDj(2) = "Adapter"
DDj(3) = "USB"
Dim ii As Integer
'DDi = 1
'DDj = 1
Numberflag = 0
DeviceFlagA = 0
DeviceFlagB = 0
'For DDi = 1 To 3
For i = 1 To 3
Device = Me.Controls.Item("DeviceDropDown" & DDi)
If Device = "Channel_Not_Available" Then
ElseIf Device = "Select Device" Then
MsgBox "Please select a number channel for" & DDi, vbCritical, "Error"
Exit For
Else
If InStr(1, Device, "Device A") Then
DeviceFlagA = 1
End If
If InStr(1, Device, "Device B") Then
DeviceFlagB = 1
End If
'For DDj = 1 To 3
For ii = 1 To 3
If DDi <> DDj Then
Device1 = Me.Controls.Item("DeviceDropDown" & DDj)
If Device1 = "Channel_Not_Available" Then
Else
If Device = Device1 Then
MsgBox "Please select different number channel for" & DDj, vbCritical, "Error"
Numberflag = Numberflag + 1
Exit For
End If
End If
End If
Next
If Numberflag >= 1 Then
Exit For
End If
End If
Next
End If
End Sub
你的意思是这样吗?
Private Sub HTNextButton_Click()
Dim Device As String
Dim DDi(1 To 3) As String
DDi(1) = "Temperature"
DDi(2) = "Adapter"
DDi(3) = "USB"
For i = 1 To 3
Device = Me.Controls.Item("DeviceDropDown" & i).Text
If Device = "Channel_Not_Available" Or Device = "Select Device" Or Device = "" Then
MsgBox "Please select a number channel for " & DDi(i), vbCritical, "Error"
Me.Controls.Item("DeviceDropDown" & i).SetFocus
Exit Sub
End If
Next
'
'
'
End Sub
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句