[Help] vb6 Reading from a random file menu

Shout-Out

User Tag List

Results 1 to 4 of 4
  1. #1
    Murdok's Avatar Member
    Reputation
    34
    Join Date
    Oct 2007
    Posts
    69
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Help] vb6 Reading from a random file

    Hi i am having a bit of trouble with reading a random file i can get it to write to a file but not get data back

    Code:
    General
    Option Explicit
    Dim outRec As PhoneRec
    Dim position As Integer
    Dim lastrecord As Integer
    Dim inRec As PhoneRec
    
    _________________________________________
    
    Form Load
    
    Dim intcnt As Integer
    For intcnt = 0 To 7
        txtInput(intcnt).Text = ""
    Next intcnt
    
    Open "c:\test.txt" For Random As #1
    
    
    Do While Not EOF(1)
        Get #1, , outRec
    Loop
    
    lastrecord = Seek(1) - 1
    position = lastrecord
    
    _________________________________________
    
    cmdRead
    
    On Error GoTo ErrRtn
    
    Dim intcnt As Integer
    Dim intcnt2 As Integer
    Dim position As Integer
    position = txtInput(0).Text
    
    Get #1, position, inRec
    
    txtInput(1).Text = inRec.Fname
    txtInput(2).Text = inRec.Lname
    txtInput(3).Text = inRec.Street
    txtInput(4).Text = inRec.city
    txtInput(5).Text = inRec.State
    txtInput(6).Text = inRec.zip
    txtInput(7).Text = inRec.Phone
    
    ErrRtn:
    Resume Next
    _________________________________________
    Module 
    
    Type PhoneRec
        Personid As Integer
        Fname As String * 15
        Lname As String * 15
        Street As String * 20
        city As String * 15
        State As String * 10
        zip As String * 8
        Phone As String * 6
    End Type
    my cmdWrite works fine and puts the data from the textboxes into the file but doesn't read them back when i click the cmdRead can anyone see any problems in the code.

    this is in VB6 by the way

    [Help] vb6 Reading from a random file
  2. #2
    ReidE96's Avatar Archer Authenticator enabled
    Reputation
    470
    Join Date
    Dec 2006
    Posts
    1,625
    Thanks G/R
    1/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    Open "c:\test.txt" For Random As #1 Len = Len(oneRec)
    And you can get the number of records with this:

    Code:
    NoOfRecords = LOF(1)/Len(oneRec)
    Also, I'd replace inRec and outRec with a single record called oneRec, seeing as it can do the same task whether it's for input or output. I used oneRec in those snippets.

  3. #3
    Murdok's Avatar Member
    Reputation
    34
    Join Date
    Oct 2007
    Posts
    69
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats worked fine +2 rep for helping, gonna have a play around seeing if i can get a few things to work, if i have any trouble can i PM you?

  4. #4
    ReidE96's Avatar Archer Authenticator enabled
    Reputation
    470
    Join Date
    Dec 2006
    Posts
    1,625
    Thanks G/R
    1/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure thing, if I can help I will Glad it helped.

Similar Threads

  1. Reading strings from WDB cache files.
    By Nesox in forum WoW Memory Editing
    Replies: 4
    Last Post: 06-08-2013, 03:03 PM
  2. LUA Help (reading from/writing to files)
    By tagala in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 10-05-2009, 06:48 PM
  3. Need Help, Please Read!
    By Fenarth in forum World of Warcraft General
    Replies: 5
    Last Post: 08-12-2007, 10:57 AM
  4. HELP: [Leggings of the Ursa] blp file!
    By mmowns in forum WoW ME Questions and Requests
    Replies: 0
    Last Post: 01-14-2007, 05:04 PM
  5. Help hiding wow from my dad
    By RichyG in forum World of Warcraft General
    Replies: 7
    Last Post: 12-01-2006, 09:09 PM
All times are GMT -5. The time now is 10:44 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search