473,327 Members | 2,025 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,327 software developers and data experts.

One-Dimensional Arrays in VB6

10
I am new to using Visual Basic and am trying to learn something about the 6.0 version. Having a problem in the area of one-dimensional arrays. After I create an array using a Dim statement and declare the values that I want, I assume that if I make another statement later it will replace the value of the original?

Dim strFamily(3) as String


strFamilyArray(1) = "Jeff"
strFamilyArray(2) = "Kay"
strFamilyArray(3) = "Billy"

--- strFamilyArray(2) = "Patrick"


In a similar light does this work using operators or what result should I expect?

Dim curPay(1 to 3) as Currency


curPay(1) = "500"
curPay(2) = "100"
curPay(3) = "300"

---curPay(2) = curPay(2) + 10 ---wasn't sure what value would be in the (2) spot with this statement, or if it would give an error message?

Thank you for your help, if you need any more info let me know~
Jan 22 '08 #1
2 1250
kadghar
1,295 Expert 1GB
(...)

--- strFamilyArray(2) = "Patrick"


In a similar light does this work using operators or what result should I expect?
(...)
curPay(2) = "100"
(...)
---curPay(2) = curPay(2) + 10 ---wasn't sure what value would be in the (2) spot with this statement, or if it would give an error message?
You should expect:

strFamilyArray(2) = "Patrick"
and
curPay(2) = 110,

It'll read the right part first, so it'll say CurPay(2) + 10 = 100 + 10 = 110 and then asign it to the left part.
You dont have to use " " in numeric values.

Give it a try by yourself.
HTH
Jan 22 '08 #2
Killer42
8,435 Expert 8TB
...if I make another statement later it will replace the value of the original?
...
curPay(2) = curPay(2) + 10
Yes, you're correct on both counts. An array variable works just the same as any other variable, so placing a value in it replaces what was there before.

And your "+ 10" sample is perfectly correct. In an assignment (=) statement, the right-hand side is evaluated first. So VB will take a copy of the current value from curPay(2), add 10 to this value, then look at the left-hand side to determine where to place the result. The fact that it happens to be a variable which was used in the calculation doesn't mean anything.

One thing I would point out. This line...
curPay(1) = "500"
while it may compile and work alright, is not technically correct. Numeric values do not use delimiters (quotes). This should be written as
curPay(1) = 500
In your version, VB has to do extra work at runtime to take the string value you've provided and convert it to a numeric value. It may not be a huge difference, but let's consider, for example, if you made a typo...
curPay(1) = "500x"
This will still compile alright. Any string is much like another, the compiler doesn't care what's in it. But when you actually try to execute that statement, you will hit a Type mismatch error.
Jan 23 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: rjl444 | last post by:
I created 2 tables with one to one relationship. if I add a record in table A, how does table B record get created? Does SQL do this automatically because it is one to one relationship? or do I...
5
by: Sami | last post by:
Please bear with me, and if you answer this question, please do it step by step. I am new at Access, not at all sophisticated. I am using Office XP. This will need to be read in Access for...
7
by: Randy Yates | last post by:
I'm a complete newbie to postgres so please look the other way if these questions are really stupid. Is it legitimate to have one database per data file? For organizational and backup purposes,...
44
by: Tolga | last post by:
As far as I know, Perl is known as "there are many ways to do something" and Python is known as "there is only one way". Could you please explain this? How is this possible and is it *really* a...
22
by: petermichaux | last post by:
Hi, I'm curious about server load and download time if I use one big javascript file or break it into several smaller ones. Which is better? (Please think of this as the first time the scripts...
3
by: nasirmajor | last post by:
dear all, a simple quetion for database experts. can three datatables be updated at the same time (from one page)with one table having one primary key and other two tables are having that primary...
2
by: Sky | last post by:
Hello: I'm trying to make sense of snk files, when to use, under what conditions to regenerate new ones,...can someone take a look if these statemes make sense? And then the final questions at the...
32
by: Matias Jansson | last post by:
I come from a background of Java and C# where it is common practise to have one class per file in the file/project structure. As I have understood it, it is more common practice to have many...
25
by: toffee | last post by:
Hi all, apologies if this seems like a pretty basic question - but can an element have more than one class? if so, how do you set them ? and how does the browser give priority to a class over...
1
by: CatchSandeepVaid | last post by:
I have posted this question in hibernate forums also.. As this forum is related to java, i am posting it here also ... In hibernate, presently one-to-one associations are fetched non-lazily... I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.