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.. =)
Printable View
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.. =)
Hello.
To what kind of message do you refer? Please be a little more specific.
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.. =)
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....
Quote:
Using File System Object
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.
Quote:
sequential File access
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.
Hope, this will help you in getting the things done...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
Post your code that extracts the data. It should be good to save at that point.
Write following code in a module.
You can call the function on any event from following code.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
'-----------------------------------------------
Code:'--Call module for logs
'------------------------------------------
Call OpenFile
Print #intFileHandle, Now; ","; modem_string_text
Close #intFileHandle
umar
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.. =)
Create a module with folowing code:
Call the function from button: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
Code:Private Sub Command1_Click()
Text1.Text = FileText("c:\data.txt")
End Sub
What do you mean by "Keil C"? Are you talking of a different programming language? :confused:
ya.. keil C is a different programming.. cause i need to use keil C to abstract the particular msg out. =)
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....
ya.. i wish to use keil C on the same computer... =)
Maybe I'd understand the actual problem if I could see the "message", you have "abstracted" (possibly meaning "extracted")... :confused: