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
vendorFields(0) = "txtVendorName. Text"
vendorFields(1) = "txtVendorStree tAddress.Text"
vendorFields(2) = "txtVendorCity. Text"
....
vendorFields(2) = "111 Star Ave"
but really i want it to translate as
txtVendorStreet Address.Text = "111 Star Ave"
I know my logic is messed up, is this possible, and if so how coud I do
it? Thanks 13 1468
James,
Why not an array of textboxes
dim myTextBoxes() as Textbox = {txtVendorName, txtVendorStreet ,etc}
venodorfields(2 ).Text = "111StarAve nue"
I hope this helps,
Cor
"James" <ja**********@g mail.comschreef in bericht
news:11******** *************@m 73g2000cwd.goog legroups.com...
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
vendorFields(0) = "txtVendorName. Text"
vendorFields(1) = "txtVendorStree tAddress.Text"
vendorFields(2) = "txtVendorCity. Text"
...
vendorFields(2) = "111 Star Ave"
but really i want it to translate as
txtVendorStreet Address.Text = "111 Star Ave"
I know my logic is messed up, is this possible, and if so how coud I do
it? Thanks
hmmm sounds like a good solution, but i also have one combo box... and
ideas how i could incorporate that into the array?
thanks.
Cor Ligthert [MVP] wrote:
James,
Why not an array of textboxes
dim myTextBoxes() as Textbox = {txtVendorName, txtVendorStreet ,etc}
venodorfields(2 ).Text = "111StarAve nue"
I hope this helps,
Cor
"James" <ja**********@g mail.comschreef in bericht
news:11******** *************@m 73g2000cwd.goog legroups.com...
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
vendorFields(0) = "txtVendorName. Text"
vendorFields(1) = "txtVendorStree tAddress.Text"
vendorFields(2) = "txtVendorCity. Text"
...
vendorFields(2) = "111 Star Ave"
but really i want it to translate as
txtVendorStreet Address.Text = "111 Star Ave"
I know my logic is messed up, is this possible, and if so how coud I do
it? Thanks
James,
That is so nice, you can use it with a combobox too.
However than you only need to change the array as
dim ctr() as controls = ............... ............
Text is a property from controls and therefore as well in the textbox as in
the combobox. You don't have to do anything more, text is inherited.
I hope this helps,
Cor
"James" <ja**********@g mail.comschreef in bericht
news:11******** ************@c2 8g2000cwb.googl egroups.com...
hmmm sounds like a good solution, but i also have one combo box... and
ideas how i could incorporate that into the array?
thanks.
Cor Ligthert [MVP] wrote:
>James,
Why not an array of textboxes
dim myTextBoxes() as Textbox = {txtVendorName, txtVendorStreet ,etc} venodorfields( 2).Text = "111StarAve nue"
I hope this helps,
Cor
"James" <ja**********@g mail.comschreef in bericht news:11******* **************@ m73g2000cwd.goo glegroups.com.. .
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
vendorFields(0) = "txtVendorName. Text"
vendorFields(1) = "txtVendorStree tAddress.Text"
vendorFields(2) = "txtVendorCity. Text"
...
vendorFields(2) = "111 Star Ave"
but really i want it to translate as
txtVendorStreet Address.Text = "111 Star Ave"
I know my logic is messed up, is this possible, and if so how coud I do
it? Thanks
Great, thanks for all your help. Much appreciated!
Cor Ligthert [MVP] wrote:
James,
That is so nice, you can use it with a combobox too.
However than you only need to change the array as
dim ctr() as controls = ............... ............
Text is a property from controls and therefore as well in the textbox as in
the combobox. You don't have to do anything more, text is inherited.
I hope this helps,
Cor
"James" <ja**********@g mail.comschreef in bericht
news:11******** ************@c2 8g2000cwb.googl egroups.com...
hmmm sounds like a good solution, but i also have one combo box... and
ideas how i could incorporate that into the array?
thanks.
Cor Ligthert [MVP] wrote:
James,
Why not an array of textboxes
dim myTextBoxes() as Textbox = {txtVendorName, txtVendorStreet ,etc}
venodorfields(2 ).Text = "111StarAve nue"
I hope this helps,
Cor
"James" <ja**********@g mail.comschreef in bericht
news:11******** *************@m 73g2000cwd.goog legroups.com...
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
vendorFields(0) = "txtVendorName. Text"
vendorFields(1) = "txtVendorStree tAddress.Text"
vendorFields(2) = "txtVendorCity. Text"
...
vendorFields(2) = "111 Star Ave"
but really i want it to translate as
txtVendorStreet Address.Text = "111 Star Ave"
I know my logic is messed up, is this possible, and if so how coud I do
it? Thanks
Cor,
Well, I thought I was done... but when my code gets to this line:
ctrTextFieldNam es(intFieldsRea d).Text =
Microsoft.Visua lBasic.Left(str ReadVendorFile, intFieldValue)
it triggers this error:
An unhandled exception of type 'System.NullRef erenceException ' 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,
txtVendorStreet Address, txtVendorCity, txtVendorState, txtVendorZip,
txtVendorPhone, txtVendorCOutst andingBill, txtVendorSalesR epName,
txtVendorCommen ts, cboVendorPerfer redPmtPeriod}
Private Sub fillTextFields( ByVal ctrTextFieldNam es() As Control)
Dim intNumOfFields As Integer = 0
Dim intFieldsRead As Integer = 0
Dim intFieldValue As Integer
Dim strFieldValue As String
strReadVendorFi le = VendorFile.Read Line()
'Store the number of records as an integer value
intNumOfFields = ctrTextFieldNam es.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(strReadVe ndorFile, ",")
'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
ctrTextFieldNam es(intFieldsRea d).Text =
Microsoft.Visua lBasic.Left(str ReadVendorFile, 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)
strReadVendorFi le =
Microsoft.Visua lBasic.Right(st rFieldValue, 100)
intFieldsRead += 1
Loop
End Sub
James wrote:
<snip>
ctrTextFieldNam es(intFieldsRea d).Text =
Microsoft.Visua lBasic.Left(str ReadVendorFile, intFieldValue)
it triggers this error:
An unhandled exception of type 'System.NullRef erenceException ' occurred
in Appointment.exe
<snip>
intNumOfFields = ctrTextFieldNam es.Length
'loop to fill all fields
Do Until intFieldsRead = intNumOfFields + 1
<snip>
I guess the previous line shoud be
Do Until intFieldsRead = intNumOfFields
HTH.
Regards,
Branco.
yeah... but it's still erroring out at that outher spot, i figured what
you just told me needed to be changed, i just wasn't sure yet.
Branco Medeiros wrote:
James wrote:
<snip>
ctrTextFieldNam es(intFieldsRea d).Text =
Microsoft.Visua lBasic.Left(str ReadVendorFile, intFieldValue)
it triggers this error:
An unhandled exception of type 'System.NullRef erenceException ' occurred
in Appointment.exe
<snip>
intNumOfFields = ctrTextFieldNam es.Length
'loop to fill all fields
Do Until intFieldsRead = intNumOfFields + 1
<snip>
I guess the previous line shoud be
Do Until intFieldsRead = intNumOfFields
HTH.
Regards,
Branco.
Sorry, no response here lately, I still am searching for an answer to
my error. Any ideas? Thanks
James wrote:
yeah... but it's still erroring out at that outher spot, i figured what
you just told me needed to be changed, i just wasn't sure yet.
Branco Medeiros wrote:
James wrote:
<snip>
ctrTextFieldNam es(intFieldsRea d).Text =
Microsoft.Visua lBasic.Left(str ReadVendorFile, intFieldValue)
>
it triggers this error:
An unhandled exception of type 'System.NullRef erenceException ' occurred
in Appointment.exe
<snip>
intNumOfFields = ctrTextFieldNam es.Length
>
'loop to fill all fields
Do Until intFieldsRead = intNumOfFields + 1
<snip>
I guess the previous line shoud be
Do Until intFieldsRead = intNumOfFields
HTH.
Regards,
Branco.
James wrote:
Sorry, no response here lately, I still am searching for an answer to
my error. Any ideas? Thanks
Well, I guess your code need some fixes... ;-)
The internal loop can be much simpler:
Private Sub fillTextFields( ByVal TextControls() As Control)
'Populates the controls in TextControls with the fields read from the
'curretn line of the vendor file
'Splits the comma separated items from the line read
'from VendorFile
Dim Texts() As String = VendorFile.Read Line().Split(", "c)
'iterates by each field and saves it on the corresponding control
For Field As Integer = 0 To _
System.Math.Min (Texts.Length, TextControls.Le ngth) - 1
TextControls(Fi eld).Text = Texts(Field).Tr im
Next
End Sub
>From a previous post:
<snip>
Private Sub fillTextFields( ByVal ctrTextFieldNam es() As Control)
Dim intNumOfFields As Integer = 0
Dim intFieldsRead As Integer = 0
Dim intFieldValue As Integer
Dim strFieldValue As String
strReadVendorFi le = VendorFile.Read Line()
strReadVendorFi le is a local string, why isn't it declared inside the
sub? Can it be you're not using "Option Explicit"? If so, you probably
mistyped a control name in your control array. Go activate Option
Explicit first, and *then* come back here... =)))
'Store the number of records as an integer value
intNumOfFields = ctrTextFieldNam es.Length
'loop to fill all fields
Do Until intFieldsRead = intNumOfFields + 1
As I told you, this line must be
Do Until intFieldsRead = intNumOfFields
'this is a comma delimited text file we are reading from
'find the length to the first comma
intFieldValue = InStr(strReadVe ndorFile, ",")
I personally preffer the intrinsic methods unless a library one
provides anything extra. In this case, *IMHO*, you should use
intFiledValue = strReadVendorFi le.IndexOf(","c )
instead of InStr... besides, intFieldValue should be named Pos,
Separator, Split, Comma etc...
'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
ctrTextFieldNam es(intFieldsRea d).Text =
Microsoft.Visua lBasic.Left(str ReadVendorFile, intFieldValue)
The same goes for the previous line: you should use (IMHO):
ctrTextFieldNam es(intFieldsRea d).Text = _
strReadVendorFi le.Substring(0, intFielValue - 1 ).Trim
'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)
strReadVendorFi le =
Microsoft.Visua lBasic.Right(st rFieldValue, 100)
Oooops, what was that? You are trying to get the rightmost 100 chars
from strFieldValue, but this string was never initialized. Therefore,
you're assigning an empty string to strReadVendorFi le.
If what you want is to discard the slice you just processed, there are
a number of approches:
strReadVendorFi le = Right(strReadVe ndorFile, _
strReadVendorFi le.Length - intFielValue)
Or
strReadVendorFi le = Mid(strReadVend orFile, intFielValue + 1)
Or
strReadVendorFi le = strReadVendorFi le.Substring(in tFielValue + 1)
Or
strReadVendorFi le = strReadVendorFi le.Remove(0, intFielValue + 1)
Etc, etc.
intFieldsRead += 1
Loop
Hmmm if you're just incrementing the intFieldsRead var (which controls
the loop) why not use a For...Next loop, instead?
<snip>
HTH.
Regards and good luck.
Branco. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nathan Rose |
last post by:
Here's my problem. I am reading from a text file using this:
if (!file_exists($file))
{
echo "Don't exist\n";
return false;
}
$fd = @fopen($file, 'r');
if (!is_resource($fd))
|
by: KellyH |
last post by:
Hi, I hope someone can point me in the right direction.
I'll get it out of the way: Yes, I am a college student. No, I am not
looking for anyone to do my homework, just looking for help. I have been
reading this ng all semester, and found it very helpful. I just have a
stupid problem going on right now.
Here's the project:
We have to...
|
by: Tommy Lang |
last post by:
I am working on this project and I need some help/pointers/comments to
get me started, I am stuck.
The program will be used to store information in an array while it is
running.
I need to store objects of my classes Person(superclass),
Student(inherit Person), Teacher(inherit Person) in that array.
The name will be the unique key. These...
|
by: ash |
last post by:
Hey I am new, but I don't have time to intruduce myself yet.
I am intro to C++
and this is a programme I have to write.
all the direction are here, It will be very nice of someone to figure
this out.
note: I only in intro C++ which is about to be finished by the next two
weeks.
The topic which I am on in my book is "POINTERS"
Text from...
|
by: vinod.bhavnani |
last post by:
Hello all,
I need desperate help
Here is the problem:
My problem today is with multidimensional arrays.
Lets say i have an array A this is a 4 dimensional
static array.
| |
by: skumar434 |
last post by:
i need to store the data from a data base in to structure
.............the problem is like this ....suppose there is a data base
which stores the sequence no and item type etc ...but i need only the
sequence nos and it should be such that i can access it through the
structure .plz help me .
|
by: gcary |
last post by:
I am having trouble figuring out how to declare a pointer to an array
of structures and initializing the pointer with a value. I've looked
at older posts in this group, and tried a solution that looked
sensible, but it didn't work right. Here is a simple example of what
I'm trying to accomplish:
// I have a hardware peripheral that I'm...
|
by: SpreadTooThin |
last post by:
If you are deriving a new class from another class,
that you must (I assume) know the initializer of the other class.
So in myClass
import array
class myClass(arrary.array):
def __init__(self, now here I need to put array's constructor
parameters..., then mine):
array.array.__init__(self, typecode)
|
by: javabeginner123 |
last post by:
i have a java prob, and i have to solve it fast, but i'm just getting to know it, so plz help me solve it with full code completed, thanks so much. the prob is to create a monter fight and there is the description:
The monsters are of a very strange kind, called "Bigmon". They have some basic characteristics, like attack and defense power, life...
|
by: jac130 |
last post by:
the program runs, and user is prompted via inputbox to enter an integer-this is the size of the array, then the user fills the array with that many values...but as the user enters the values, i need to check and make sure that none of hte values have already been entered in the array, if it has..then there must be a message telling user to enter a...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |