Hi All
I am sending 13 characters to my vb6 prog via comms which works most of the time but then for some reason the 13th character becomes the first character and it does this all the time until i reload my vb6 program example:-
1907122220870 is how it should be but ends up like 0190712222087 help would be very greatful
RegardsCode:Private Sub Form_Load() Dim textfile As String Open "C:\users\administrator\dirnames.txt" For Input As #1 Do While Not EOF(1) Input #1, textfile FolderCreator.Combo1.AddItem (textfile) Loop Close #1 ' Show Date on main screen. 'Label3.Caption = DateValue(Now) ' Fire Rx Event Every Two Bytes MSComm1.RThreshold = 13 ' When Inputting Data, Input 2 Bytes at a time MSComm1.InputLen = 13 ' 9600 Baud, No Parity, 8 Data Bits, 1 Stop Bit MSComm1.Settings = "9600,N,8,1" ' Disable DTR MSComm1.DTREnable = False ' Open COM1 MSComm1.CommPort = 1 MSComm1.PortOpen = True MSComm1.InBufferCount = 0 End Sub Private Sub MSComm1_OnComm() Dim sData As String ' Holds our incoming data Dim lHighByte As Long ' Holds HighByte value Dim lLowByte As Long ' Holds LowByte value Dim lWord As Long ' Holds the Word result ' If comEvReceive Event then get data and display If MSComm1.CommEvent = comEvReceive Then ' Shell ("subst Z: /D") 'Shell ("net use /Delete Z:") sData = MSComm1.Input ' Get data (5 bytes) ' lHighByte = Asc(Mid$(sData, 1, 1)) ' get 1st byte ' lLowByte = Asc(Mid$(sData, 2, 1)) ' Get 2nd byte ' Combine bytes into a word ' lWord = (lHighByte * &H100) Or lLowByte ' Convert value to a string and display ' lblRCTime.Caption = sData ' MkDir sData ' Dim folder As String, filename As String, path As String Label8.Caption = sData 'MSComm1.Output = sData Dim wshThisShell As WshShell Dim lngRet As Long Dim strShellCommand As String Dim strBatchPath As String 'label8.caption = "" Set wshThisShell = New WshShell strBatchPath = "c:\deletevert.bat" 'the path for the batch file you're using strShellCommand = """" & strBatchPath & """" 'the ridiculous number of quotation marks is necessary 'when there is a space in one or more of the folder names lngRet = wshThisShell.Run(strShellCommand, vbNormalFocus, vbTrue) 'set 3rd argument above to vbFalse for asynchronous 'execution of the batch file. 'label8.caption = "" 'label9.caption = "" If Dir$("e:\" & sData, vbDirectory) = "" Then Label9.Caption = "Directory does not exist." MkDir "e:\" & sData MkDir "e:\" & sData & "\" & FolderCreator.Combo1.List(0) MkDir "e:\" & sData & "\" & FolderCreator.Combo1.List(1) MkDir "e:\" & sData & "\" & FolderCreator.Combo1.List(2) MkDir "e:\" & sData & "\" & FolderCreator.Combo1.List(3) MkDir "e:\" & sData & "\" & FolderCreator.Combo1.List(4) MkDir "e:\" & sData & "\" & FolderCreator.Combo1.List(5) MkDir "e:\" & sData & "\" & FolderCreator.Combo1.List(6) MkDir "e:\" & sData & "\" & FolderCreator.Combo1.List(7) MkDir "e:\" & sData & "\" & FolderCreator.Combo1.List(8) MkDir "e:\" & sData & "\" & FolderCreator.Combo1.List(9) MkDir "e:\" & sData & "\" & FolderCreator.Combo1.List(10) MkDir "e:\" & sData & "\" & FolderCreator.Combo1.List(11) MkDir "e:\" & sData & "\" & FolderCreator.Combo1.List(12) MkDir "e:\" & sData & "\" & FolderCreator.Combo1.List(13) MkDir "e:\" & sData & "\" & FolderCreator.Combo1.List(14) 'Shell ("subst F: " & "e:\" & sData) Shell ("net use Z: " & "\\ENDOFLINE\STORAGE\" & sData & " /persistent:yes") Shell ("net use Z: " & "\\ENDOFLINE\STORAGE\" & sData & " /persistent:yes") MSComm1.Output = sData
Steve


Reply With Quote

