473,388 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Control Array Erroring Out... Help Plz.

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

Oct 8 '06 #1
0 678

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: nobody | last post by:
hello everybody, is there a way of creating an array with help of a function that would accept the name of this array as a parameter and then create global Array type variable of that name? so...
0
by: mrwoopey | last post by:
Hi, Instead of using the Japanese version of the OLAP control for vs.net there is now an English version: Visual Studio .NET Web Control for Business Intelligence - ...
0
by: MrMike | last post by:
I'm having problem with code that I originally obtained from: http://support.microsoft.com/default.aspx?scid=kb;... This code is supposed to loop through datagrid rows and determine which rows...
4
by: Rich | last post by:
I am close than I was before and I thank y'all for your Great Help!! I wrote the following script with help. So far it does what I want, it will prompt user for Input, then Display the User's...
9
by: ckerns | last post by:
I want to loop thru an array of controls,(39 of them...defaults = 0). If value is null or non-numeric I want to assign the value of "0". rowString = "L411" //conrol name if (isNaN(eval...
2
by: Tarren | last post by:
Hi: The problem I am having is when I validate an xml file to a schema, it is erroring out every element. I think this has something to do with me defining/referencing the namespaces. I have...
104
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from...
13
by: James | last post by:
Is this possible? I want to pass an array into a function that contains txtBox.Text properties... I was thinking something like this, but I know it won't work Dim vendorFields(9) As String ...
1
by: David C | last post by:
I have a DropDownList control that is bound to a table with an ID and name. i added a selection option called <newwith a value = -1. When I choose this -1 value record I use OnSelectedIndexChange...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.