in my windows form table, im doing an addressbook for college course and i did a notepad for the contacts but im having trouble importing them into my address table textbox i put.
can you have a look and see what ive done wrong in my code
Public Class Addressbook
Structure Contacts
Dim Fname As String
Dim Surname As String
Dim Address As String
Dim City As String
Dim Postcode As String
Dim Country As String
Dim NextOfKin As String
End Structure
Dim peoplelist(100) As Contacts
Dim Counter As Integer = 0
Dim Recordnumber As Integer = 0
Dim filename As String = "names.txt"
Dim fieldterminator As String = "#"
Dim count As Integer
Private Sub Addressbook_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If My.Computer.FileSystem.FileExists(filena... Then
Dim content As String
content = My.Computer.FileSystem.ReadAllText(filen...
Dim record() As String = content.Split(Environment.NewLine)
For i As Integer = 0 To record.Length - 7
If record(i).Trim %26lt;%26gt; String.Empty Then
Dim field() As String = record(i).Split(fieldterminator)
peoplelist(i).Fname = field(0).Trim
peoplelist(i).Surname = field(1).Trim
peoplelist(i).Address = field(2).Trim
peoplelist(i).City = field(3).Trim
peoplelist(i).Postcode = field(4).Trim
peoplelist(i).Country = field(5).Trim
peoplelist(i).NextOfKin = field(6).Trim
End If
Next
Recordnumber = record.Length - 2
Else
MsgBox("file" + filename + "does not exist", , "Missing file")
End If
Counter = 0
updatescreen()
End Sub
Sub savefile()
savescreen()
If My.Computer.FileSystem.FileExists(filena... Then
My.Computer.FileSystem.DeleteFile(filena...
End If
For i As Integer = 0 To Counter
Dim recordcontact As String = record(i).Fname = recordcontact + fieldterminator + (i).Surname
recordcontact = recordcontact + Enviroment.Newline
My.Computer.FileSystem.WriteAllText(file... recordcontact
Next
updatescreen()
End Sub
Private Sub Passcode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Passcode.Click
Securitypasscode.Show()
Me.Hide()
End Sub
Sub savescreen()
filename = Counter + 0
peoplelist(Counter).Fname = TextBox1.Text
peoplelist(Counter).Surname = TextBox2.Text
peoplelist(Counter).Address = TextBox3.Text
peoplelist(Counter).City = TextBox4.Text
peoplelist(Counter).Postcode = TextBox5.Text
peoplelist(Counter).Country = TextBox6.Text
peoplelist(Counter).NextOfKin = TextBox7.Text
End Sub
Sub updatescreen()
TextBox1.Text = peoplelist(Counter).Fname
TextBox2.Text = peoplelist(Counter).Surname
TextBox3.Text = peoplelist(Counter).Address
TextBox4.Text = peoplelist(Counter).City
TextBox5.Text = peoplelist(Counter).Postcode
TextBox6.Text = peoplelist(Counter).Country
TextBox7.Text = peoplelist(Counter).NextOfKin
nme.Text = Recordnumber + 1 %26amp; "of" %26amp; Counter + 1
End Sub
Visual basics 2005 express edition coding help. how do i get the notepad writting to appear in the my textbox?
No one is going to wade through all that code (especially the way Yahoo forces it to be unformatted). Tell us where the problem is, or exactly what it;s not doing or what line throws what error. (I'd use at least a datagrid for data of this type, but it's your program.)
Reply:I agree with Colanth on this one, I started trying to go through your code, but you don't even have any comments and you don't following any consistent coding style for example, all methods should begin with a capital letter, all variables should begin with a small letter with each word in the name delineated by camel notation, all these small factors play a huge role in the code readability. Also when providing code examples never replace code with "...".
If you have the option of choosing how the data is stored I'd use an XML file, that way you can use a XPath query to go directly to information that you require, although this may require you to add an additional filed such as an ID which will be a unique integer.
rose garden
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment