-
November 9th, 2006, 12:05 PM
#1
need help urgently... =)
hi.. i need to extract a message from VB6.0 and save it into a file in my computer. Do anyone know the command to extract the msg out from the program and save it as a text in my desktop?? i seriously need help urgently..
thanks alot.. =)
-
November 9th, 2006, 12:30 PM
#2
Re: need help urgently... =)
Hello.
To what kind of message do you refer? Please be a little more specific.
-
November 9th, 2006, 07:45 PM
#3
Re: need help urgently... =)
i am actually suppose to get a msg from the modem.. i am already able to abstract that particular msg but i dunno how to save tt msg into a text file and save it in my computer.
thanks.. =)
-
November 9th, 2006, 08:15 PM
#4
Re: need help urgently... =)
you can use the fileSystem object to store that msg...but before that could u plz, let us know, that u getting the message as a string or any other format? if u getting the message as a string, then store it in a string variable or in a Array (do not forget to redim and preserv the content of the array, if you want to keep that for future use). create a object of the filesystem object and open a text file and save, else you can do it other way, like open a sequential file.
if you want to store the data in the same file again and again, then use the following API functions to read from and to write to the file....
Code:
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("c:\testfile.txt", True)
MyFile.WriteLine("This is a test.")
MyFile.Close
'c:\testfile.txt needs to replaced with the file path you want to keep the data.
Code:
Dim iFreeFileNum as integer
iFreeFileNum=FreeFile
open "C:\sample.txt" for output as #iFreeFileNum
print #iFreeFileNum, sMessage
close #iFreeFileNum
''c:\sample.txt needs to replaced with the file path you want to keep the data.
Code:
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" _
(ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, _
ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" _
(ByVal lpSectionName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Hope, this will help you in getting the things done...
-
November 9th, 2006, 08:32 PM
#5
Re: need help urgently... =)
Post your code that extracts the data. It should be good to save at that point.
-
November 10th, 2006, 12:44 AM
#6
Re: need help urgently... =)
Write following code in a module.
Code:
'--Module Code
'-------------------------------------------
Public intFileHandle
Public Sub OpenFile()
'*********Open File for Writing
Dim FileName As String
Dim fso As New FileSystemObject
If Not fso.FolderExists(App.Path & "\Logs") Then
fso.CreateFolder App.Path & "\Logs"
End If
intFileHandle = FreeFile
FileName = App.Path & "\logs\Log-" & Day(Date) & "-" & MonthName(Month(Date)) & ".txt"
Open FileName For Append As #intFileHandle
End Sub
'-----------------------------------------------
You can call the function on any event from following code.
Code:
'--Call module for logs
'------------------------------------------
Call OpenFile
Print #intFileHandle, Now; ","; modem_string_text
Close #intFileHandle
umar
Last edited by umararif; November 10th, 2006 at 12:59 AM.
-
December 3rd, 2006, 11:11 PM
#7
Re: need help urgently... =)
hi.. i have managed to abstract the message out from VB 6.0.. thanks for your help. but now i need to put the message into a new programming name "Keil C" do any1 know how do i abstract the message from the notepad and display it in keil C?? thanks for your help.. =)
-
December 4th, 2006, 05:40 AM
#8
Re: need help urgently... =)
Create a module with folowing code:
Code:
Function FileText(ByVal filename As String) As String
Dim handle As Integer
If Len(Dir$(filename)) = 0 Then
Err.Raise 53 ' File not found
End If
handle = FreeFile
Open filename$ For Binary As #handle
FileText = Space$(LOF(handle))
Get #handle, , FileText
Close #handle
End Function
Call the function from button:
Code:
Private Sub Command1_Click()
Text1.Text = FileText("c:\data.txt")
End Sub
-
December 4th, 2006, 07:32 AM
#9
Re: need help urgently... =)
What do you mean by "Keil C"? Are you talking of a different programming language?
-
December 6th, 2006, 12:44 PM
#10
Re: need help urgently... =)
ya.. keil C is a different programming.. cause i need to use keil C to abstract the particular msg out. =)
-
December 6th, 2006, 12:53 PM
#11
Re: need help urgently... =)
well do you want keil c to display the msg on the same computer or on the development board?
keil c is used for development boards....
Last edited by Lkr299; December 6th, 2006 at 12:56 PM.
-
December 6th, 2006, 09:11 PM
#12
Re: need help urgently... =)
ya.. i wish to use keil C on the same computer... =)
-
December 7th, 2006, 10:08 AM
#13
Re: need help urgently... =)
Maybe I'd understand the actual problem if I could see the "message", you have "abstracted" (possibly meaning "extracted")...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|