用vb编程,怎么从excel或txt(有n行6列)中取其中一列数据,要一个一个的取,小弟菜鸟,望大虾指教
答案:2 悬赏:60 手机版
解决时间 2021-12-25 19:23
- 提问者网友:咪咪
- 2021-12-24 20:24
取数据的时间间隔可以设定
最佳答案
- 五星知识达人网友:往事隔山水
- 2021-12-24 21:22
Private Sub ComSend1_Click()
Dim fs As Variant
Dim a As String Dim i As Long
Dim filepath As String Dim m
filepath = App.Path & "\abc.txt" '文本文档名称为 123.txt
Open filepath For Input As #1
Line Input #1, a
Close #1
m = Split(a, ",")
If UBound(m) = 0 Then
Exit Sub '如果发送数据为空则退出过程
ElseIf MSComm1.PortOpen = False Then
MsgBox "串口未打开!", 64, "提示"
Exit Sub
End If
MSComm1.Settings = com_setting fs = Replace(TextSend.Text, " ", "")
For i = LBound(m) To UBound(m)
fs = CStr(Abs(m(i)))
MSComm1.Output = fs
Label11.Caption = Len(strsend) '发送计数
Next i
Close #1
End Sub
Dim fs As Variant
Dim a As String Dim i As Long
Dim filepath As String Dim m
filepath = App.Path & "\abc.txt" '文本文档名称为 123.txt
Open filepath For Input As #1
Line Input #1, a
Close #1
m = Split(a, ",")
If UBound(m) = 0 Then
Exit Sub '如果发送数据为空则退出过程
ElseIf MSComm1.PortOpen = False Then
MsgBox "串口未打开!", 64, "提示"
Exit Sub
End If
MSComm1.Settings = com_setting fs = Replace(TextSend.Text, " ", "")
For i = LBound(m) To UBound(m)
fs = CStr(Abs(m(i)))
MSComm1.Output = fs
Label11.Caption = Len(strsend) '发送计数
Next i
Close #1
End Sub
全部回答
- 1楼网友:骨子里都是戏
- 2021-12-24 22:06
你好!
dim i as long
for i=1 to n
msgbox cells(i,x)
next
x表示你要读取的列
打字不易,采纳哦!
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯