i have a prob, when the report is written in a notepad, i can only click on stop button then click play again to stop the the report to write in a sequence .... need help on it how to break the sequence without pressing the stop button....
C:\Documents and Settings\T070702\Desktop\02B01P0600679FN.dat
--------------------------------------------------------------
Error Record = Record Count is mismatch
Error Line =
Error Line =
Error Line =
Error Line =
Debit Purse is not match
Debit Non Purse is not match
Hash Total Purse is not match
Hash Total NonPurse is not match
C:\Documents and Settings\T070702\Desktop\04P32P1004099FN.dat
--------------------------------------------------------------
Error Record = Error
Error Line = mfgNo line =11 mfgNo line =15 mfgNo line =19 mfgNo line =778 mfgNo line =780
Error Line = crdtraNo line =780
Error Line =
Error Line =
Your problem is not clear.
Please explain it without giving the out put of the text file.
well i thought tat it would be easier since im not good in explaining.... anyway i 'll try.... the writing in the notepad is continous while i want it to be in two different notepad ... or i cannot stop the shell function....... without pressing the stop button...... haiyo i really bad in explaining.....
well i thought tat it would be easier since im not good in explaining.... anyway i 'll try.... the writing in the notepad is continous while i want it to be in two different notepad ... or i cannot stop the shell function....... without pressing the stop button...... haiyo i really bad in explaining.....
Shell function, people use it for interactive mode. So writing to one notepad file will continue in operation until youabandon that shell. After that you have to activate the shell for the next notepad. It also will continue in interactive mode until stoped.
Anyhow, without seeing your piece of code, I won't be able to tell you where exactly the bug.
regards
AV Manoharan
yea i think so . thnx... u 've answered it. anyway this is the code
Private Sub CmdChkFile_Click()
Dim fs As FileSystemObject
Dim ts As TextStream, ts1 As TextStream, ts2 As TextStream
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile(DatFName, ForReading)
Set ts1 = fs.OpenTextFile(HdrFName, ForReading)
Set ts2 = fs.CreateTextFile(DatFName & "_" & Format(Date, "ddmmyy") & ".rpt")
Dim MyVar As String, MyCheck As String
Dim line As Integer, totalline As Integer, i As Integer
Dim SumCP, SumCN, SumDP, SumDN
Dim HashTPurse, HashTNPurse
Do While Not ts.AtEndOfStream
d = ts.ReadLine
Call tracingFNDat(Mystring)
'function '
line = line + 1
If Trim(Mfgno) = "" Then lbl2.Caption = lbl2.Caption & " mfgNo line =" & line
If Trim(CardTran) = "" Then lbl3.Caption = lbl3.Caption & " crdtraNo line =" & line
totalline = line
Loop
Do While Not ts1.AtEndOfStream
h = ts1.ReadLine
Call tracingFNHdr(Mystring)
Loop
If Trim(RecordCount) <> totalline Then lbl1.Caption = "-BV03- Record Count is mismatch"
If totalline = 0 Then lbl1.Caption = " -BV10- Record Error "
If Val(CP) <> SumCP Then lbl8.Caption = lbl8.Caption & " -BV04- Credit Purse mismatch"
If Val(DP) <> SumDP Then lbl9.Caption = lbl9.Caption & " -BV04- Debit Purse mismatch"
If Val(CN) <> SumCN Then lbl10.Caption = " -BV05- Credit Non Purse mismatch"
HashTPurse = SumCP - SumDP
HashTNPurse = SumCN - SumDN
'Writing'
vmsg = vmsg & DatFName & Chr$(13) & Chr$(10) & _
"--------------------------------------------------------------" & Chr$(13) & Chr$(10) & _
"Error Record = " & lbl1.Caption & Chr$(13) & Chr$(10) & _
"Error Line = " & lbl2.Caption & Chr$(13) & Chr$(10) & _
"Error Line = " & lbl3.Caption & Chr(13) & Chr$(10) & _
"Error Line = " & lbl4.Caption & Chr(13) & Chr$(10) & _
"Error Line = " & lbl5.Caption & Chr(13) & Chr$(10) & _
lbl8.Caption & Chr$(13) & Chr$(10) & _
lbl9.Caption & Chr$(13) & Chr$(10) & _
lbl10.Caption & Chr$(13) & Chr$(10) & _
lbl11.Caption & Chr$(13) & Chr$(10) & _
lbl12.Caption & Chr$(13) & Chr$(10) & _
lbl13.Caption & Chr$(13) & Chr$(10) _
& Chr$(13) & Chr$(10) & Chr$(13) & Chr$(10) _
& Chr$(13) & Chr$(10) & Chr$(13) & Chr$(10) _
ts2.WriteLine (vmsg)
Call Shell("notepad.exe " & (DatFName & "_" & Format(Date, "ddmmyy") & ".rpt"), ForReading)
is there anyway to close this notepad??? that's what im thinking actually... anyway millions of thank you
End Sub
yea i think so . thnx... u 've answered it. anyway this is the code Private Sub CmdChkFile_Click() Dim fs As FileSystemObject Dim ts As TextStream, ts1 As TextStream, ts2 As TextStream Set fs = CreateObject("Scripting.FileSystemObject") Set ts = fs.OpenTextFile(DatFName, ForReading) Set ts1 = fs.OpenTextFile(HdrFName, ForReading) Set ts2 = fs.CreateTextFile(DatFName & "_" & Format(Date, "ddmmyy") & ".rpt") Dim MyVar As String, MyCheck As String Dim line As Integer, totalline As Integer, i As Integer Dim SumCP, SumCN, SumDP, SumDN Dim HashTPurse, HashTNPurse Do While Not ts.AtEndOfStream d = ts.ReadLine Call tracingFNDat(Mystring) 'function ' line = line + 1 If Trim(Mfgno) = "" Then lbl2.Caption = lbl2.Caption & " mfgNo line =" & line If Trim(CardTran) = "" Then lbl3.Caption = lbl3.Caption & " crdtraNo line =" & line totalline = line Loop Do While Not ts1.AtEndOfStream h = ts1.ReadLine Call tracingFNHdr(Mystring) Loop If Trim(RecordCount) <> totalline Then lbl1.Caption = "-BV03- Record Count is mismatch" If totalline = 0 Then lbl1.Caption = " -BV10- Record Error " If Val(CP) <> SumCP Then lbl8.Caption = lbl8.Caption & " -BV04- Credit Purse mismatch" If Val(DP) <> SumDP Then lbl9.Caption = lbl9.Caption & " -BV04- Debit Purse mismatch" If Val(CN) <> SumCN Then lbl10.Caption = " -BV05- Credit Non Purse mismatch" HashTPurse = SumCP - SumDP HashTNPurse = SumCN - SumDN 'Writing' vmsg = vmsg & DatFName & Chr$(13) & Chr$(10) & _ "--------------------------------------------------------------" & Chr$(13) & Chr$(10) & _ "Error Record = " & lbl1.Caption & Chr$(13) & Chr$(10) & _ "Error Line = " & lbl2.Caption & Chr$(13) & Chr$(10) & _ "Error Line = " & lbl3.Caption & Chr(13) & Chr$(10) & _ "Error Line = " & lbl4.Caption & Chr(13) & Chr$(10) & _ "Error Line = " & lbl5.Caption & Chr(13) & Chr$(10) & _ lbl8.Caption & Chr$(13) & Chr$(10) & _ lbl9.Caption & Chr$(13) & Chr$(10) & _ lbl10.Caption & Chr$(13) & Chr$(10) & _ lbl11.Caption & Chr$(13) & Chr$(10) & _ lbl12.Caption & Chr$(13) & Chr$(10) & _ lbl13.Caption & Chr$(13) & Chr$(10) _ & Chr$(13) & Chr$(10) & Chr$(13) & Chr$(10) _ & Chr$(13) & Chr$(10) & Chr$(13) & Chr$(10) _ ts2.WriteLine (vmsg) Call Shell("notepad.exe " & (DatFName & "_" & Format(Date, "ddmmyy") & ".rpt"), ForReading) is there anyway to close this notepad??? that's what im thinking actually... anyway millions of thank you End Sub
The streams are to be closed for further opening. so afterts2.writeline(vmsg)
you close both by
ts.close and ts2.close
then open it as below.
Dim MyNote1 As String
MyNote1 ="%SystemRoot%\system32\notepad.exe " & (DatFname1 & .....etc. then
Shell MyNote1, vbMaximizedFocus
See, I did not test it. But the above logic is very correct.
Rest is up to you.
Happy Programming
AV Manoharan
Av Manoharan
Thnx for your help n respond, but I somehow couldnt get the file open with %SystemRoot%\system32\ , what exactly does it do ? dumping memory ? an error runtime 53 occured when I compile ..... any Idea?
wait now i can run it ..... but the same problem occured .... " continous output " mayb your r right , we cannot stop it without pressing the stop button...
thnx AV Manoharan
I've just received this ... they said it can stop it ...
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_CLOSE = &H10
Public Function callfun()
Shell "C:\RSSB.exe 1", vbMaximizedFocus
End Function
Public Function clsExe()
Dim winHwnd As Long
Dim RetVal As Long
winHwnd = FindWindow(vbNullString, "RSSB")
If winHwnd <> 0 Then
' MsgBox "calc is closing"
PostMessage winHwnd, WM_CLOSE, 0&, 0&
Else
'MsgBox "The Calculator is not open."
End If
End Function
Do you have any Idea about this?
ok i've used the above function, it can close my notepad but it still couldn't stop the process without pressing the stop button .... just wanna share ..
See coco,
The above program is to call the RSSB.exe program in
interactive mode by the shell, similier to your Notepad
The clsExe function (of course, it is to be called after
some time-delay, otherwise in a flicker both functions
will be executed.), then resize it to 0 length which
automatically finds it place in the taskbar.
But that doesn't solve your problem. Because it will be
alive there until you interactively close it.
If you are more interested in it, I can give you the
logic.
As you know any running program can be killed by the
task manager(ctrl-alt-del). If you can integrate it in
your vb, it is good. I remember studying it in my unix
class about killing a process that you own (or all
process for root), invoking their processor id. Windows
can't be different. Just search in the net. You may find
it. I have not yet, tried it.
Regards
AV Manoharan