當前位置:編程學習大全網 - 編程軟體 - 用vb編程,怎麽從excel或txt(有n行6列)中取其中壹列數據,要壹個壹個的取,小弟菜鳥,望大蝦指教

用vb編程,怎麽從excel或txt(有n行6列)中取其中壹列數據,要壹個壹個的取,小弟菜鳥,望大蝦指教

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

  • 上一篇:如何用ug繪制形狀的互補性
  • 下一篇:慕課網編程課程怎麽樣?我登陸網站發現有好多細分類目,這些都是程序員要掌握的知識麽?
  • copyright 2024編程學習大全網