Hi all
First post here. I'm new at all this VB.Net stuff, but an old hand at using VBA, but all though the two are related there's such a huge difference that I'm still finding my feet. As practice I'm making a very simple contacts form reading information in from a .txt file. Each different field uses a delimiter of ASCII character 1-7, to help me identify the field. Now last night I had this thing running beautifully and I did something stupid and tinkered with the code, now one line is showing an error, and I can't figure out why. VB very helpfully offers to run the last good build for me, but won't show me the code.
Would somebody pleeeeaaaaase put me out of my misery and back on the right track.
It's the bit in red that has the dreaded blue squiggly line under it and I'm taunted by the error message "Number of indices is less than the number of dimensions of the indexed array."
A big fat (virtual) ice cream to the one who can end my torment.
Thanks for reading.
DominicB
First post here. I'm new at all this VB.Net stuff, but an old hand at using VBA, but all though the two are related there's such a huge difference that I'm still finding my feet. As practice I'm making a very simple contacts form reading information in from a .txt file. Each different field uses a delimiter of ASCII character 1-7, to help me identify the field. Now last night I had this thing running beautifully and I did something stupid and tinkered with the code, now one line is showing an error, and I can't figure out why. VB very helpfully offers to run the last good build for me, but won't show me the code.
Would somebody pleeeeaaaaase put me out of my misery and back on the right track.
VB.NET:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim fileReader As String = My.Computer.FileSystem.ReadAllText("C:\AddressBook.txt")
Dim Names() As String
Dim Address1() As String, Address2() As String
Dim Address3() As String, Address4() As String
Dim Postcode() As String, Telephone() As String
Dim Counter1 As Long = 1, Counter2 As Long = 0
Dim fields() As String
Dim delimiters() As Char = {Chr(1), Chr(2), Chr(3), Chr(4), Chr(5), Chr(6), Chr(7), Chr(8)}
fields[COLOR="Red"]()[/COLOR] = fileReader.Split(delimiters)
ReDim Names(UBound(fields) / 7)
ReDim Address1(UBound(fields) / 7)
ReDim Address2(UBound(fields) / 7)
ReDim Address3(UBound(fields) / 7)
ReDim Address4(UBound(fields) / 7)
ReDim Postcode(UBound(fields) / 7)
ReDim Telephone(UBound(fields) / 7)
While Counter1 < (UBound(fields) / 7) + 1
Names(Counter1) = fields(Counter2)
Counter2 = Counter2 + 1
Address1(Counter1) = fields(Counter2)
Counter2 = Counter2 + 1
Address2(Counter1) = fields(Counter2)
Counter2 = Counter2 + 1
Address3(Counter1) = fields(Counter2)
Counter2 = Counter2 + 1
Address4(Counter1) = fields(Counter2)
Counter2 = Counter2 + 1
Postcode(Counter1) = fields(Counter2)
Counter2 = Counter2 + 1
Telephone(Counter1) = fields(Counter2)
Counter2 = Counter2 + 1
Counter1 = Counter1 + 1
End While
End Sub
A big fat (virtual) ice cream to the one who can end my torment.
Thanks for reading.
DominicB