I'm trying to reassign text fields based upon the the values being read
in. It errors out when it gets to:
ctrTextFieldNames(intFieldsRead).Text =
Microsoft.VisualBasic.Left(strReadVendorFile, intFieldValue)
it triggers this error:
"An unhandled exception of type 'System.NullReferenceException'
occurred
in Appointment.exe
Additional information: Object reference not set to an instance of an
object."
Here's the code so you can get a feel of that line in context. Thanks
for your help.
Dim ctrvendorFields() As Control = {txtVendorName,
txtVendorStreetAddress, txtVendorCity, txtVendorState, txtVendorZip,
txtVendorPhone, txtVendorCOutstandingBill, txtVendorSalesRepName,
txtVendorComments, cboVendorPerferredPmtPeriod}
Private Sub btnVendorReadFirst_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnVendorReadFirst.Click
fillTextFields(ctrvendorFields)
End Sub
Private Sub fillTextFields(ByVal ctrTextFieldNames() As Control)
Dim intNumOfFields As Integer = 0
Dim intFieldsRead As Integer = 0
Dim intFieldValue As Integer
Dim strFieldValue As String
strReadVendorFile = VendorFile.ReadLine()
'Store the number of records as an integer value
intNumOfFields = ctrTextFieldNames.Length
'loop to fill all fields
Do Until intFieldsRead = intNumOfFields + 1
'this is a comma delimited text file we are reading from
'find the length to the first comma
intFieldValue = InStr(strReadVendorFile, ",")
'based on the position of the first commma, write the value
on the left
'side of the comma to the .Text property of the record in
the Control Array
ctrTextFieldNames(intFieldsRead).Text =
Microsoft.VisualBasic.Left(strReadVendorFile, intFieldValue)
'redefine the string so it only contains the remaining
comma delimited fields
'figure out a way to have a flexible value (ie the 100
needs to change)
strReadVendorFile =
Microsoft.VisualBasic.Right(strFieldValue, 100)
intFieldsRead += 1
Loop
End Sub