there is a an type mismatch error i am getting, when i want to creat an XL file for my code.
this is my code and i am trying to write XL file for the values i am scanning in the main code. can anybody please help me to get it through.
Code:
Private Sub Command6_Click()
' Forward mode1
Dim scanner As Integer
Dim StrMsgn As Integer
Dim Forwardn As Integer
Dim StoreVal(20) As Integer
'StrMsgn = "forwardn" & vbCrLf
For Forwardn = 0 To Text9.Text
If CInt(Text1.Text) > 0 And CInt(Text1.Text) < 1000 Then
For a = 1 To CInt(Text1.Text)
'For a = 1 To 20
'MsgBox ("Please set number of steps from 0 to 999.")
USB1.WR_P0 (1)
Sleep (Speed)
USB1.WR_P0 (2)
Sleep (Speed)
USB1.WR_P0 (4)
Sleep (Speed)
USB1.WR_P0 (8)
Sleep (Speed)
Next a
' switch current to zero
USB1.WR_P0 (0)
Sleep (2)
'StrMsgn = StrMsgn & Forwardn & "," & vbCrLf
Else
MsgBox ("Please set number of steps from 0 to 999.")
End If
StoreVal(0) = USBvolt.VOLT_CH1
For scanner = 1 To Text8.Text
Sleep (500)
StoreVal(scanner) = USBvolt.VOLT_CH1
Text5.Text = StoreVal(scanner)
Next scanner
Next Forwardn
'Call WriteInfo(StrMsgn)
End Sub
Private Function WriteInfo(WriteForwardn As String)
Dim Forwardn As Integer 'making forward n times
Dim fson, txtfile
Set fso = CreateObject("Scripting.FileSystemObject")
Set txtfile = fso.CreateTextFile(App.Path & "\testn.csv", True)
txtfile.Write (WriteStr) ' Write a line.
txtfile.Close
End Function
Comment