ComboBox问题,在线等~~~

fengkoulangjian 2007-01-16 11:41:54
我想把一些指令顺序排列在一个ComboBox中,点击"执行"button时能够顺序执行ComboBox中的这些指令,能实现么?该怎么做?

如一些发送给串口的指令,我点"执行"后,这些排列在ComboBox中的指令就一条一条的连续发送出去.

谢谢,帮我!
...全文
200 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
fengkoulangjian 2007-01-17
  • 打赏
  • 举报
回复
谢谢水如烟,虽然我只有20可用分,一直耐心帮我~~~感谢你!
fengkoulangjian 2007-01-16
  • 打赏
  • 举报
回复
该怎么做?
水如烟 2007-01-16
  • 打赏
  • 举报
回复
如果你这种方法,要Do While 或 Do Until,就是参考Do Loop
水如烟 2007-01-16
  • 打赏
  • 举报
回复
那不行,没有遍历.是这样的:

For i As Integer = 0 To Me.ComboBox1.Items.Count - 1

Me.ComboBox1.SelectedIndex = i

If Me.ComboBox1.Text.Contains("/") Then
Me.SerialPort1.Write(Me.ComboBox1.Text)
End If

If Me.ComboBox1.Text.Contains("ms") Then
Me.Button14_Click(sender, e)
End If

Next i
fengkoulangjian 2007-01-16
  • 打赏
  • 举报
回复
谢谢水如烟,我自己也试着写了一点儿,你能帮我看看么?如下:
Me.ComboBox1.SelectedIndex = 0
Dim int As Integer = 0 - 1
int += 1
If int <= Val(Me.ComboBox1.Items.Count) Then
Me.ComboBox1.SelectedIndex = int
If Me.ComboBox1.Text.Contains("/") Then
Me.SerialPort1.Write(Me.ComboBox1.Text)
End If
If Me.ComboBox1.Text.Contains("ms") Then
Me.Button14_Click(sender, e)
End If
End If
不用管它的意思,可以运行么?
leq_82 2007-01-16
  • 打赏
  • 举报
回复
楼上正解
水如烟 2007-01-16
  • 打赏
  • 举报
回复
Public Class ActionsDemo
Private gActions As String() = New String() {"A", "B", "C"}

Public ReadOnly Property Actions() As String()
Get
Return gActions
End Get
End Property

Private Sub [do](ByVal action As String)
Select Case action
Case "A"
DoA()
Case "B"
DoB()
Case "C"
DoC()
End Select
End Sub

Private Sub DoA()
Console.WriteLine("A")
End Sub

Private Sub DoB()
Console.WriteLine("B")
End Sub

Private Sub DoC()
Console.WriteLine("C")
End Sub

Public Sub DoAll()
For Each action As String In gActions
[do](action)
Next
End Sub

End Class
fengkoulangjian 2007-01-16
  • 打赏
  • 举报
回复
帮帮我呀~~~

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧