VB把数据保存到EXCEL
我想帮串口接收到得数据保存到EXCEL里面,写到这里不知道怎么写了,就是想让MSComm触发的时候把收到的数据写到EXCEL里去,现在我只能用手动发过去,还不能换行,不能保存,能不能让VB控制EXCEL的保存,保存到指定的路径,文件名为保存时间2011.06.13/11,第一行自动写成序号,名称等,让数据从地2行开始保存。
Option Explicit
Dim xlapp As Variant
Dim xlBook As Variant
Dim xlSheet As Variant
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer
Dim e As Integer
Dim f As Integer
Dim g As Integer
Private Sub Command1_Click()
a = a + 2
b = b + 3
c = c + 4
d = d + 5
e = e + 6
f = f + 7
g = g + 8
xlSheet.Cells(2, a) = Text2.Text
xlSheet.Cells(2, b) = Text3.Text
xlSheet.Cells(2, c) = Text4.Text
xlSheet.Cells(2, d) = Text5.Text
xlSheet.Cells(2, e) = Text6.Text
xlSheet.Cells(2, f) = Text7.Text
xlSheet.Cells(2, g) = Text8.Text
End Sub
Private Sub Form_Load()
Set xlapp = CreateObject("excel.application")
xlapp.Visible = True
Set xlBook = xlapp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
MSComm1.Settings = "9600,n,8,1"
MSComm1.CommPort = 3
MSComm1.NullDiscard = False
MSComm1.RThreshold = 57
MSComm1.InputMode = comInputModeText
MSComm1.PortOpen = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
xlapp.Quit '关闭EXCEL
Set xlapp = Nothing '释放EXCEL对象
End Sub
Private Sub MSComm1_OnComm()
Text1.Text = MSComm1.Input
Text2.Text = Mid(Text1, 6, 10)
Text3.Text = Mid(Text1, 17, 8)
Text4.Text = Mid(Text1, 33, 6)
Text5.Text = Mid(Text1, 39, 3)
Text6.Text = Mid(Text1, 44, 2)
Text7.Text = Mid(Text1, 49, 4)
Text8.Text = Mid(Text1, 54, 2)
End Sub
Option Explicit
Dim xlapp As Variant
Dim xlBook As Variant
Dim xlSheet As Variant
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer
Dim e As Integer
Dim f As Integer
Dim g As Integer
Private Sub Command1_Click()
a = a + 2
b = b + 3
c = c + 4
d = d + 5
e = e + 6
f = f + 7
g = g + 8
xlSheet.Cells(2, a) = Text2.Text
xlSheet.Cells(2, b) = Text3.Text
xlSheet.Cells(2, c) = Text4.Text
xlSheet.Cells(2, d) = Text5.Text
xlSheet.Cells(2, e) = Text6.Text
xlSheet.Cells(2, f) = Text7.Text
xlSheet.Cells(2, g) = Text8.Text
End Sub
Private Sub Form_Load()
Set xlapp = CreateObject("excel.application")
xlapp.Visible = True
Set xlBook = xlapp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
MSComm1.Settings = "9600,n,8,1"
MSComm1.CommPort = 3
MSComm1.NullDiscard = False
MSComm1.RThreshold = 57
MSComm1.InputMode = comInputModeText
MSComm1.PortOpen = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
xlapp.Quit '关闭EXCEL
Set xlapp = Nothing '释放EXCEL对象
End Sub
Private Sub MSComm1_OnComm()
Text1.Text = MSComm1.Input
Text2.Text = Mid(Text1, 6, 10)
Text3.Text = Mid(Text1, 17, 8)
Text4.Text = Mid(Text1, 33, 6)
Text5.Text = Mid(Text1, 39, 3)
Text6.Text = Mid(Text1, 44, 2)
Text7.Text = Mid(Text1, 49, 4)
Text8.Text = Mid(Text1, 54, 2)
End Sub
...全文
相关推荐
vb中将数据保存到excel
实现数据从MSFlexgrid中保存到excel中,自动创建excel
VB MySQL数据库结构分析并保存到EXCEL
VB MySQL数据库结构分析并保存到EXCEL
VB对ACESS数据库的基本操作,适合新手,包括对数据库的添加,删除和修改,以及导出成EXCEL格式保存
VB对ACESS数据库的基本操作,适合新手,包括对数据库的添加,删除和修改,以及导出成EXCEL格式保存
Warner-v1.0-VB6-project-:一个学生指导过程,学生可以在其中输入反馈数据。 指导者只会登录并单击保存。 数据将保存在Access数据库的Excel文件中
Warner-v1.0-VB6-project-:一个学生指导过程,学生可以在其中输入反馈数据。 指导者只会登录并单击保存。 数据将保存在Access数据库的Excel文件中
vb调用excel实例
主要是VB调用excel实现数据录入及保存


数据库(包含打印,安装,报表)
