I'm a beginner in VB.Net. I'm actually taking a class & so far I
understand everything, but I suck when it comes to arrays. I'm sure
that this is simple (I'm ashamed of asking :oops: )...
I have some textboxes. I'm trying to store the information in an
array, but I'm lost as to how: I have textboxes for FirstName,
LastName & PhoneNumber.
My problem is that the number of arrays is unknown so our teacher
wants us to declare it as (0) to begin with...this is what I have.
Can someone PLEASE point me to the right direction?
'Declaring the arrays
Dim strFirstName() As String
Dim strLastName() As String
Dim strPhone() As String
Dim intNum As Integer
Private Sub btnSave_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSave.Click
'1st try
intNum = intNum + 1
strFirstName(intNum) = txtFirstName.Text
intNum = intNum + 1
strLastName(intNum) = txtLastName.Text
intNum = intNum + 1
strPhone(intNum) = txtPhone.Text
'2nd try
intNum = intNum + 1
For intNum = intNum To intNum
strFirstName(intNum) = txtFirstName.Text
Next
I'm clueless as to what to try next. Please HELP!!! Thanks. :cry:
:cry: 9 1353
Not exactly sure what you are trying to do but see comments inline:
"NewInTheGame" <bo*********@yahoo-dot-com.no-spam.invalid> wrote in message
news:41**********@Usenet.com... I'm a beginner in VB.Net. I'm actually taking a class & so far I understand everything, but I suck when it comes to arrays. I'm sure that this is simple (I'm ashamed of asking :oops: )...
I have some textboxes. I'm trying to store the information in an array, but I'm lost as to how: I have textboxes for FirstName, LastName & PhoneNumber.
My problem is that the number of arrays is unknown so our teacher wants us to declare it as (0) to begin with...this is what I have. Can someone PLEASE point me to the right direction?
'Declaring the arrays Dim strFirstName() As String Dim strLastName() As String Dim strPhone() As String
Dim intNum As Integer
Private Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
'1st try intNum = intNum + 1
Use the shorthand operand for this (more in line with how most other
languages do it)
intNum +=1
Also, why start intNum at one when arrays start from zero? You will never
have an item zero in your array.
strFirstName(intNum) = txtFirstName.Text
If you increase intNum here then you will have a strFirstName(1) and an
strLastName(2), but never a strLastName(1).
intNum = intNum + 1 strLastName(intNum) = txtLastName.Text intNum = intNum + 1 strPhone(intNum) = txtPhone.Text
'2nd try intNum = intNum + 1 For intNum = intNum To intNum
This loop would not run since you are starting and ending at the same
number.
strFirstName(intNum) = txtFirstName.Text Next
I'm clueless as to what to try next. Please HELP!!! Thanks. :cry: :cry:
Can you be more specific about what exactly you are trying to do? You say
the number of arrays is unknown. What does this mean? Do you just want to
store the data from the three textboxes in an array?
"NewInTheGame" <bo*********@yahoo-dot-com.no-spam.invalid> wrote in message
news:41**********@Usenet.com... My problem is that the number of arrays is unknown so our teacher wants us to declare it as (0) to begin with...this is what I have. Can someone PLEASE point me to the right direction?
It would seem you would want a two-dimensional array. But if you're confined
to one dimension...
'Declaring the arrays Dim strFirstName() As String Dim strLastName() As String Dim strPhone() As String
Dim intNum As Integer
Private Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
'1st try intNum = intNum + 1 strFirstName(intNum) = txtFirstName.Text intNum = intNum + 1 strLastName(intNum) = txtLastName.Text intNum = intNum + 1 strPhone(intNum) = txtPhone.Text
If you do it this way you'll have no way of matching the firstname and
lastname, for instance. What you want is something like:
strFirstName(intNum)=txtFirstName.Text
strLastName(intNum)=txtLastName.Text
strPhoneName(intNum)=txtPhone.Text
intNum +=1
That way the "0" index of each array will hold the first person's info,
index "1" of each array will hold the second person's info, etc.
Hi New,
I think that your teacher want to have an answer from you what array you go
using is more important than how you are using that in this case.
To help you a little bit, you have three choises you can make, you use a
standard fixed array which you can redimension everytime, you use a dynamic
array (as well named collection), or you make your own arrayclass.
It is not for us to give solutions on homework in this newsgroup, I hope
that it helps you however to give you these hints.
Cor
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Or*************@TK2MSFTNGP12.phx.gbl... It is not for us to give solutions on homework in this newsgroup, I hope that it helps you however to give you these hints.
Sorry, Cor. I didn't know that. In the future I'll try to provide "hints"
instead of "full code" answers. Thanks.
Hi Ricky,
Why "Sorry", luckily my hint was clear and I tried to point it not to you,
because I was sure you did not know that. You only did try to help.
:-)
Cor It is not for us to give solutions on homework in this newsgroup, I hope that it helps you however to give you these hints.
Sorry, Cor. I didn't know that. In the future I'll try to provide "hints" instead of "full code" answers. Thanks.
On 26 Jul 2004 23:02:39 -0500, NewInTheGame wrote: My problem is that the number of arrays is unknown so our teacher wants us to declare it as (0) to begin with...this is what I have. Can someone PLEASE point me to the right direction?
If you need to resize the array, please have a look at the ReDim command
--
Chris
dunawayc[AT]sbcglobal_lunchmeat_[DOT]net
To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
:D
Thank you guys so much!!!!! :P
I'm at work now, but as soon as I go home I'm going to give these a
try.
I REALLY appreciate your response :)
Hi
I think u canuse Redim with memory allocation
even u don't know how many rec. u have to enter Do with Redim preserve arrayname()
regards
saradhi
"NewInTheGame" wrote: :D
Thank you guys so much!!!!! :P
I'm at work now, but as soon as I go home I'm going to give these a try.
I REALLY appreciate your response :)
Ok....Just in case anybody else needs to know, I needed to ReDim the
array. Found out that I was trying to do a dinamic array...Again,
thank you guys for everything.... :wink: This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mike Lundell |
last post by:
what's wrong with this, and .. can you not declare "char" variables?
#include <iostream>
int main()
{
int a = "* * * * * * * *\n";
std::cout << a;
return EXIT_SUCCESS;
}
|
by: lokman |
last post by:
Hi,
In the following code, can someone tell me the difference between *p++ and
p++ ? I can see both achieve the same result.
Thanks a lot !
|
by: Alan |
last post by:
hi all,
I want to define a constant length string, say 4
then in a function at some time, I want to set the string to a constant
value, say a
below is my code but it fails
what is the correct...
|
by: karan.shashi |
last post by:
Hey all,
I was asked this question in an interview recently:
Suppose you have the method signature
bool MyPairSum(int array, int sum)
the array has all unique values (no repeats), your...
|
by: Armand |
last post by:
Hi Guys,
I have a set of array that I would like to clear and empty out.
Since I am using "Array" not "ArrayList", I have been struggling in
finding the solution which is a simple prob for those...
| |
by: Michael |
last post by:
Hi,
I am trying to pass a function an array of strings, but I am having trouble
getting the indexing to index the strings rather than the individual
characters of one of the strings.
I have...
|
by: Acolyte |
last post by:
Preface: Yes, I know. I'm a noob. I'm currently in an Intro to Programming class at university. So, I'm betting everybody here can answer this question, and I'm gonna feel silly for not knowing the...
|
by: paul.denlinger |
last post by:
Please excuse this very basic question; I'm just starting to learn
JavaScript.
I have just modified added a toUpperCase statement to change strings
to upper case, but it does not run.
Can you...
|
by: sam |
last post by:
hI,
I am little confused here
See
i have
int wordlen=10;
when int s is array
s++;
whats the meaning of this
|
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,...
|
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...
| |
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
|
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...
|
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 ...
|
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...
| |