[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

Structure HELP!!!

I have this sub in my code.

Public Sub get_data(ByRef first() As String, ByRef last() As String, ByRef email() As String)

        Dim counter As Integer

        'Open the text file so we can read the data into the array
        FileOpen(1, "testfile.txt", OpenMode.Input)
        counter = 0
        tCounter = 0

        Do Until (EOF(1))
            Input(1, aFname(counter))
            Input(1, aLname(counter))
            Input(1, aEmail(counter))
            counter += 1
            tCounter += 1
        Loop

        FileClose(1)
 End Sub

I need to change the arrays to a structure, so I created my structure

Public Structure user_data
      Public fName As String
      Public lName As String
      Public eMail As String
End Structure

Now the input you need to pass the file number, and a ByRef Value as an Object what should I use? I tried to do this but it didn't work.

Public info_data(25) As user_data

Public Sub get_data(ByRef data_temp As user_data)

but when I ran the software I still don't see any data on my info_data


what I'm trying to do is to read a text file, where I have some information, and store on my structure. When I use array it works, but I need to do with structure.
0
Enniobozzetti
Asked:
Enniobozzetti
1 Solution
 
S-TwilleyCommented:
Try:

Public Sub get_data(ByRef data_temp As user_data())

===============================================
If that doesn't work, use this:

Public Class user_data
      Public fName As String = ""
      Public lName As String = ""
      Public eMail As String = ""
End Class

Public Sub get_data(ByRef data_temp As user_data())
        Dim counter As Integer

        'Open the text file so we can read the data into the array
        Dim f as integer
        f = freefile
        FileOpen(f, "testfile.txt", OpenMode.Input)
        data_temp(counter) = new user_data
        counter = 0
        tCounter = 0

        Do Until (EOF(f))
            Input(f, data_temp(counter).fName)
            Input(f, data_temp(counter).lName)
            Input(f, data_temp(counter).eMail)
            counter += 1
            tCounter += 1
        Loop

        FileClose(f)
 End Sub
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now