ok guys I took a quick break from programming trying to also enjoy my summer...so I have this problem Im trying to read and write to. the pproblem describes customer accounts on which it wants me to create a structure to store data for the customer accounts which include: Last name, First name, Customer Number, Address,City,State, zip, phone number, account balance, Date of Last payment. The problem says the user should be allow to save customer accpunt records to the file and search by last name or customer number and print a report listing all customer records in the file.
heres what I have so far, and I would like to know if Im off to a decent start:
I would also like some tips on designing my GUI because so far(my window I have for the save/open windown is a huge text box and in its filter properrty I have the text files code, would this form be all that it needs when the user saves and opens the file or is it more....
also for GUI on my first form that I have shown is a huge listbox in which the names are stored and just two buttons I have Exit and Get Employee Information
Im testing for input validation also so I know I would need a tryphase or try catch as statement to.
I also posted this on the msdn network but got no answer, so maybe I can get some help here....
heres what I have so far, and I would like to know if Im off to a decent start:
VB.NET:
Option Strict On
Option Explicit On
Imports System.IO
Module modCustomerAccounts
Public Structure Customers
Dim LastName As String
Dim FirstName As String
Dim CustomerNumber As Integer
Dim Address As String
Dim City As String
Dim State As String
Dim ZipCode As Integer
Dim PhoneNumber As Integer
Dim AccountBalance As Integer
Dim LastPayment As Date
End Structure
Public gCustomer() As Customers
Public gFileName As String = ""
Public Sub LoadCustomer(ByVal fileName As String)
Dim strCustomerLine As String
Dim CustomerInformation() As String
gCustomer = Nothing
If File.Exists(fileName) Then
Dim sr As New StreamReader(fileName)
While Not sr.EndOfStream
strCustomerLine = sr.ReadLine
CustomerInformation = strCustomerLine.Split(",".ToCharArray)
AddCustomerInformation(CustomerInformation(0), CustomerInformation(1), CustomerInformation(2), _
CustomerInformation(3), CustomerInformation(4), _
CustomerInformation(5), CustomerInformation(6), CustomerInformation(7), _
CustomerInformation(8), CustomerInformation(9))
End While
sr.Close()
gFileName = fileName
End If
End Sub
Public Sub SaveCustomers(ByVal fileName As String)
Dim sw As New StreamWriter(fileName)
For i = 0 To gCustomer.Length - 1
With gCustomer(i)
sw.Write(.LastName & ",")
sw.Write(.FirstName & ",")
sw.Write(.CustomerNumber & ",")
sw.Write(.Address & ",")
sw.Write(.City & ",")
sw.Write(.State & ",")
sw.Write(.ZipCode & ",")
sw.Write(.PhoneNumber & ",")
sw.Write(.AccountBalance & ",")
sw.Write(.LastPayment & ",")
End With
Next i
sw.Close()
End Sub
Public Sub AddCustomer(ByVal lastName As String, ByVal firstName As String, ByVal customerNumber As Integer, _
ByVal address As String, ByVal city As String, _
ByVal state As String, ByVal zipCode As Integer, ByVal phoneNumber As Integer, _
ByVal accountBalance As Integer, ByVal lastPayment As Date)
If gCustomer Is Nothing Then
ReDim gCustomer(0)
Else
ReDim Preserve gCustomer(gCustomer.Length)
End If
With gCustomer(gCustomer.Length - 1)
.LastName = lastName
.FirstName = firstName
.LastName = lastName
.CustomerNumber = customerNumber
.Address = address
.City = city
.State = state
.ZipCode = zipCode
End With
End Sub
End Module
I would also like some tips on designing my GUI because so far(my window I have for the save/open windown is a huge text box and in its filter properrty I have the text files code, would this form be all that it needs when the user saves and opens the file or is it more....
also for GUI on my first form that I have shown is a huge listbox in which the names are stored and just two buttons I have Exit and Get Employee Information
Im testing for input validation also so I know I would need a tryphase or try catch as statement to.
I also posted this on the msdn network but got no answer, so maybe I can get some help here....