Show you're code you're using and i'll have a look at it
Printable View
Show you're code you're using and i'll have a look at it
kedaman, here's the code, such as it is. thanks for looking at it.
Don Goyette
[email protected]
---------------------------------------------
Private stCraftDir As String
Private Sub ActiveBar21_ToolClick(ByVal Tool As ActiveBar2LibraryCtl.Tool)
If Len(stCraftDir) = 0 Then
'stCraftDir = CurDir()
stCraftDir = "C:\craft"
End If
Select Case Tool.Name
Case "miCraftware": craft
Case "miCalLoad": CalLoad
Case "miCheckFiles": CheckFiles
Case "miCaPrint": CaPrint
Case "miExit": End
End Select
End Sub
Private Sub craft() 'run campaign craftware
Dim RetVal
Form1.Show
RetVal = Shell(stCraftDir + "\craft3.exe", 1)
End Sub
Private Sub CalLoad() 'run CalLoad (upload to sec'y of state)
Dim RetVal
RetVal = Shell(stCraftDir + "\cal\CALoad.exe", 1)
End Sub
Private Sub CaPrint() 'print upload file
Dim RetVal
RetVal = Shell(stCraftDir + "\cal\CaPrint.exe", 1)
End Sub
Private Sub CheckFiles()
Dim TaskID, RetVal As String
CommonDialog1.ShowOpen
pid = Shell(stCraftDir + "\cal\Caervw.exe " + CommonDialog1.FileName + _
" >" + stCraftDir + "\el\validtext.txt", 4)
RetVal = TextSrch(stCraftDir + "\el\validtext.txt", "return code:")
iretval = Val(Mid(RetVal, 13))
If iretval < 2 Then
intMsgBox = MsgBox("Passed OK: " + RetVal, vbCritical, "Verify")
Else
intMsgBox = MsgBox("Failed: " + RetVal, vbCritical, "Verify")
End If
End Sub
Private Function TextSrch(stFilename, stSrchStr) As String
' searches stFilename for line containing stSrchStr string and returns it
Dim stLine As String
lensrchstr = Len(stSrchStr)
'kedaman: this is where it fails as there is no
'file named stCraftDir + "\el\validtext.txt" (stCraftDir)
Open stFilename For Input As #1
Do While Not EOF(1)
Line Input #1, stLine
lenline = Len(stLine)
For ichar = 1 To lenline - lensrchstr + 1
If Mid(stLine, ichar, lensrchstr) = stSrchStr Then
TextSrch = Mid(stLine, ichar)
Exit For
End If
Exit Do
Next 'For ichar = 1 To lenline - lensrchstr + 1
Loop 'Do While Not EOF(1)
End Function
I don't have ActiveBar2LibraryCtl or cal\Caervw.exe so i can't test it out but it's possible that you can't execute a file and return the output in a file, i haven't done that so i can't tell you
Just 'shelling' out won't allow you to redirect output to a file, this is your problem.
In a DOS window this would work:
dir *.* >dir.txt
You would end up with a dir.txt containing a text listing of the directory.
Doing the same in VB using 'shell' will NOT work
You need to add 'command.com'
You have to change it to:
Shell ("c:\command.com /c dir c:\*.* >c:\dir.txt")
This would now work from within VB