CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13
  1. #1
    Join Date
    Sep 2006
    Posts
    9

    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.. =)

  2. #2
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: need help urgently... =)

    Hello.
    To what kind of message do you refer? Please be a little more specific.

  3. #3
    Join Date
    Sep 2006
    Posts
    9

    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.. =)

  4. #4
    Join Date
    Jun 2005
    Location
    Orissa
    Posts
    150

    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....

    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.
    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.
    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...

  5. #5
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: need help urgently... =)

    Post your code that extracts the data. It should be good to save at that point.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  6. #6
    Join Date
    Oct 2006
    Posts
    65

    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.

  7. #7
    Join Date
    Sep 2006
    Posts
    9

    Smile 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.. =)

  8. #8
    Join Date
    Oct 2006
    Posts
    65

    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

  9. #9
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: need help urgently... =)

    What do you mean by "Keil C"? Are you talking of a different programming language?

  10. #10
    Join Date
    Sep 2006
    Posts
    9

    Re: need help urgently... =)

    ya.. keil C is a different programming.. cause i need to use keil C to abstract the particular msg out. =)

  11. #11
    Join Date
    Nov 2006
    Posts
    16

    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.

  12. #12
    Join Date
    Sep 2006
    Posts
    9

    Re: need help urgently... =)

    ya.. i wish to use keil C on the same computer... =)

  13. #13
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    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
  •  





Click Here to Expand Forum to Full Width

Featured