首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

vb 编译异常

2012-01-07 
vb 编译错误以下代码编译错误,变量错误。小弟百思不得其解,希望各位达人帮帮小弟!Option ExplicitPrivate S

vb 编译错误
以下代码编译错误,变量错误。小弟百思不得其解,希望各位达人帮帮小弟!

Option Explicit

Private Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.RThreshold = 1
MSComm1.InputMode = comInputModeBinary
MSComm1.PortOpen = True
Dim i, j As Integer
i = i + 1
j = j + 1
Dim test As Variant
Dim filename As String
filename = Date

Dim xlapp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
End Sub

Private Sub MSComm1_OnComm()


Set xlapp = CreateObject("Excel.Application")

Set xlbook = xlapp.Workbooks.Add

Set xlsheet = xlbook.Worksheets(1)

xlsheet.Cells(i, j) = "yy"


xlapp.Visible = False

xlbook.SaveAs "d:\" & filename & Left(Time, 5) & "-" & Mid(Time, 7, 2) & "-" & Right(Time, 2)


xlbook.Close False
xlapp.Quit

End Sub


[解决办法]

VB code
Option ExplicitDim xlapp As Excel.ApplicationDim xlbook As Excel.WorkbookDim xlsheet As Excel.WorksheetDim test As VariantDim filename As StringDim i, j As IntegerPrivate Sub Command1_Click()MSComm1.CommPort = 1MSComm1.RThreshold = 1MSComm1.InputMode = comInputModeBinaryMSComm1.PortOpen = Truei = i + 1j = j + 1filename = DateEnd Sub 

热点排行