Results 1 to 20 of 20

Thread: Retrieve data from a text file and display in a textbox.

Threaded View

  1. #1

    Thread Starter
    Member seraphicmortal's Avatar
    Join Date
    May 2005
    Posts
    56

    Resolved Retrieve data from a text file and display in a textbox.

    Hi! I hope someone could help me with this.

    I want to retrieve data saved in .pnp file and display it in the same txtboxes and same order as it was saved.

    My current code is:

    VB Code:
    1. (globalvar.bas)
    2. Option Explicit
    3.  
    4. Public pn1 As New partnamelist
    5.  
    6. (frm_field)
    7. Private Sub fieldupload()
    8.     With pn1 'I made a class named partnamelist having these 4 properties: part, description, quantity, and version
    9.         .part = txt_part.text
    10.         .description = txt_desc.Text
    11.         .quantity = txt_qty.Text
    12.         .version = txt_version.Text
    13.     End With
    14. End Sub
    15.  
    16. Private Sub cmd_apply_Click()
    17. dim filename as string    
    18.     If Len(txt_part.text) = 0 And _
    19.        Len(txt_desc.Text) = 0 And _
    20.        Len(txt_qty.Text) = 0 And _
    21.        Len(txt_version.Text) = 0 Then
    22.         MsgBox "please enter the necessary values."
    23.         txt_part.setfocus
    24.     Else
    25.         fieldupload
    26.         filename = txt_filename.text 'Specified filename of the user
    27.         MsgBox ("Creating profile...  Please choose what directory to save your profile.")
    28.         frm_dir.Show vbModal
    29.     End If
    30. End Sub
    31.  
    32.  
    33. '(frm_dir)
    34.  
    35. Private Sub Form_Load()
    36.     txt_pnprofile.Text = frm_field.filename + ".pnp"     '--> "pnp" here in my example is my chosen extension.
    37. End Sub
    38.  
    39. Private Sub cmd_ok_Click()
    40.     txt_profilepath.Text = file1.Path & file1.FileName & "\" &  txt_plprofile.Text 'file1 is a file listbox btw
    41.         MsgBox "Saving " & txt_profilepath & " as new profile."
    42.         SaveProfile txt_profilepath.Text, pn1
    43.     profilepath = txt_profilepath.Text
    44. End Sub
    45.  
    46. Private Sub SaveProfile(WhatFile As String, TheProfile As namelist)
    47. Dim FreeFileHandle  As Integer
    48.  
    49.     FreeFileHandle = FreeFile
    50.     Open WhatFile For Output As FreeFileHandle
    51.     With TheProfile
    52.         Print #FreeFileHandle, "[Part] " & .part
    53.         Print #FreeFileHandle, "[Description] " & .description
    54.         Print #FreeFileHandle, "[Quantity] " & .quantity
    55.         Print #FreeFileHandle, "[Version] " & .version
    56.     End With
    57.     Close FreeFileHandle
    58. End Sub

    Output of egfile.pnp:
    [Description] b42
    [MakerCode] c65
    [PartnameCode] x32
    [Quantity] x75
    [SymbolicCode] q21

    After clicking RETRIEVE button, I want that b42 will be displayed in txt_description.text and so on and so forth.

    How do I do this? I don't know how to use Line Input # Statement as well.

    Anybody, pls. help.
    Last edited by seraphicmortal; May 23rd, 2005 at 12:02 AM. Reason: [RESOLVED]

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