Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timer Events - Please Help

Status
Not open for further replies.

sbarber007

IS-IT--Management
Aug 17, 2012
1
0
0
GB
Basicly I want to add to my vb6 code. At the bottom I have marked in red below what I require.

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 = 1 ' Is this correct
' When Inputting Data, Input 2 Bytes at a time
MSComm1.InputLen = 13 ' Is this correct

' 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 ' Do I need this
End Sub


Private Sub MSComm1_OnComm()

'
' Assumes RTHreshold Property is set to a value > 0
' (Recommended value is 1)
'
Static strBuffer As String
Dim strData As String
Dim strRX As String
Dim boComplete As Boolean
Select Case MSComm1.CommEvent
Case comEvReceive
strData = MSComm1.Input
strBuffer = strBuffer & strData
Do
If Len(strBuffer) >= 13 Then
strRX = Mid$(strBuffer, 1, 13)
'
' rest of your code goes here - strRX contains the 13 characters sent
' After you've done all your processing add the following code

' START OF MY SCRIPT

Label8.Caption = strData
'MSComm1.Output = strData
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 = Chr$(34) & strBatchPath & Chr$(34)
'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:\" & strData, vbDirectory) = "" Then

Label9.Caption = "Directory does not exist."
MkDir "e:\" & strData
MkDir "e:\" & strData & "\" & FolderCreator.Combo1.List(0)
MkDir "e:\" & strData & "\" & FolderCreator.Combo1.List(1)
MkDir "e:\" & strData & "\" & FolderCreator.Combo1.List(2)
MkDir "e:\" & strData & "\" & FolderCreator.Combo1.List(3)
MkDir "e:\" & strData & "\" & FolderCreator.Combo1.List(4)
MkDir "e:\" & strData & "\" & FolderCreator.Combo1.List(5)
MkDir "e:\" & strData & "\" & FolderCreator.Combo1.List(6)
MkDir "e:\" & strData & "\" & FolderCreator.Combo1.List(7)
MkDir "e:\" & strData & "\" & FolderCreator.Combo1.List(8)
MkDir "e:\" & strData & "\" & FolderCreator.Combo1.List(9)
MkDir "e:\" & strData & "\" & FolderCreator.Combo1.List(10)
MkDir "e:\" & strData & "\" & FolderCreator.Combo1.List(11)
MkDir "e:\" & strData & "\" & FolderCreator.Combo1.List(12)
MkDir "e:\" & strData & "\" & FolderCreator.Combo1.List(13)
MkDir "e:\" & strData & "\" & FolderCreator.Combo1.List(14)

Shell ("net use Z: " & "\\ENDOFLINE\STORAGE\" & strData & " /persistent:yes")
Shell ("net use Z: " & "\\ENDOFLINE\STORAGE\" & strData & " /persistent:yes")
MSComm1.Output = strData

Else

ViewRejects.ViewList.AddItem strData & " REJECTED ON " & Now
Label5.Caption = ViewRejects.ViewList.ListCount
Label9.Caption = "Directory exists."
Shell ("net use Z: " & "\\ENDOFLINE\STORAGE\" & strData & " /persistent:yes")
Shell ("net use Z: " & "\\ENDOFLINE\STORAGE\" & strData & " /persistent:yes")
MSComm1.Output = strData
I want to create a text file here called "SHIFT 06:30 - 14:30.txt" to capture the strdata from every engine between this time and then create another text file call "SHIFT 14:30 - 22:30.txt" to capture the strdata from every engine between this time and then create another text file call "SHIFT 22:30 - 06:30.txt" to capture the strdata from every engine between this time I know how to create the text file with data the bit i dont understand is setting the time limits for each shift.
Open "e:\REJECTS.txt" For Append As #1
' For I = 0 To Lis't1.ListCount - 1
Print #1, strData & " REJECTED ON " & Now
' Next
Close #1

Open "e:\" & strData & "\REJECTS.txt" For Append As #2
' For I = 0 To Lis't1.ListCount - 1
Print #2, strData & " REJECTED ON " & Now
' Next
Close #2
End If
End If
' THE REST OF YOUR SCRIPT got compile error below

If Len(strBuffer) = 13 Then
strBuffer = ""
boComplete = True
Else
strBuffer = Mid$(strBuffer, 14)
End If
Else ' I get Compile Error Else Without IF
boComplete = True
End If
Loop Until boComplete = True
End Select
End Sub

Kind Regards

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top