Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello all, this is my first post to these boards though I have been using them as a resource for a couple of months now. I am taking my first programming class and I have a question. I have created a class called EmployeeList I need to create a method via the constructor that accepts one argument:The name of a sequential file to read. As it reads the file it will populate an array of Employee structures that is hidden from the developer. Here is what I have so far..not much, but damn IO confuses me almost as much as dynamic arrays do..Thanks in advance for the help

Option Explicit On

Option Strict On

 

Imports System.Convert

Imports System.IO

 

 

 

 

Namespace Employees

 

 

 

Public Class EmployeeList

Public Structure Employee

Public ID As Integer

Public LastName As String

Public FirstName As String

Public SSN As String

Public HourlyWage As Double

Public HoursWorked As Double

 

Public Function FullName() As String

Return FirstName & " " & LastName

End Function

 

Public Function Pay() As Double

Return HourlyWage * HoursWorked

End Function

End Structure

Private SampleRecord() As Employee

End Class

  • *Experts*
Posted

You can make a constructor for your class like this:

'constructor is always callled New
Public Sub New(ByVal filepath As String) 'Accept a string that will contain the path
'do something with the file
End Sub

Also if you need an array that needs to change size dynamically you could consider using an ArrayList, in which you can put any object and expand it as you need to.

Posted

I was actually going in the right direction!

 

Thanks a bunch for the advice. I read ahead a bit and found out a little bit bout Array Lists. They seem so much more robust/useful for my purpose. Still dont have all the syntax down pat but at least I wont look like a total bufoon when I go to get help from my professor. Can anyone recommend a vb.net syntax book?

  • *Experts*
Posted
I wouldnt recommend a book on syntax as much as a book that covers the Framework itself. If you want to lean about the syntax then simply reading several pages from MSDN collection will get you up and running with the syntax,

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...