Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Arrays In VB


How do I make an array that for instance "string" has value 4 and "string2" has value 6 etc?
How do I retrieve the values?
Thanks!!!




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Complex Multi-dimensional Variant Arrays Holding Other Arrays (sub-arrays?)
Hi there folks, I have a rather complicated problem on my hands at the mo for which I can't find a solution alone!

I'm currently working on some software for my company to keep a weekly record of the following:

Various receipts (i.e. cash, cheque, card, other & additional information, each additionally entered by the user as a daily total)

Expenses for business stock, recorded per supplier on a purchase by purchase basis

Other various expenses, i.e. motor fuel, phone, light, heat etc. on a weekly basis.

The form to which the above relates to is attached and viewing it would help you understand what I mean.


***Please note, when viewing the form, the project within VB6 should have the component "Microsoft Tabbed Dialog Control" activated in order to view it properly!***


I have already thought of a way to use multi-dimensional variant arrays to store data week by week, which, although I have not yet written the code for, I imagine would be fairly easy to accomplish.

My problem is that I have just purchased one of Microsoft's books on Visual Basic, "Programming Visual Basic 6.0" written by Francesco Balena, which has given me a completely alternative approach on how to deal with the week by week data.

It must be mentioned that although my original method I presume will work fine, MOST of the data (i.e. text boxes if you view my form )for each week will be left blank which is a waste of time and will slow down my application down.

Francesco Balena mentions in his book that an array can also hold an additional array (see page 177, if you have the book, "Arrays of arrays") saving memory for the application.

My original method is to basically create a multi-dimensional array, collecting ALL data for each week, including those which are NIL. A ROUGH example is as follows:

arr(wkNo,DayNo,ReceiptType,)    'ReceiptType as integer
arr(wkNo,ExpenseType)    'ExpenseType as integer

As I mentioned, there will be a lot of memory wasted with this type of array as not every different type of expense will be encountered each week. (I.e. once the array has been created during run-time, there will be a fixed number of entries for each dimension)

Francesco's book mentions an array that can hold an additional array, a sub-array. Something that looks like arr(1)(2) for example.

Although I can roughly grasp the method in particular, I am trying to find out a way how I can create a "sub-array" to deal with the week by week expenses so that they can be stored as need be, but when there is no data to save, then no sub-array is created.

Sorry if the above sounds confusing, but I can't think of any better way to describe what's going on! Like I said, have a look at the attached form!

Complex Multi-dimensional Variant Arrays Holding Other Arrays (sub-arrays?)
Hi there folks, I have a rather complicated problem on my hands at the mo for which I can't find a solution alone!

I'm currently working on some software for my company to keep a weekly record of the following:

Various receipts (i.e. cash, cheque, card, other & additional information, each additionally entered by the user as a daily total)

Expenses for business stock, recorded per supplier on a purchase by purchase basis

Other various expenses, i.e. motor fuel, phone, light, heat etc. on a weekly basis.

The form to which the above relates to is attached and viewing it would help you understand what I mean.


I have already thought of a way to use multi-dimensional variant arrays to store data week by week, which, although I have not yet written the code for, I imagine would be fairly easy to accomplish.

My problem is that I have just purchased one of Microsoft's books on Visual Basic, "Programming Visual Basic 6.0" written by Francesco Balena, which has given me a completely alternative approach on how to deal with the week by week data.

It must be mentioned that although my original method I presume will work fine, MOST of the data (i.e. text boxes if you view my form )for each week will be left blank which is a waste of time and will slow down my application down.

Francesco Balena mentions in his book that an array can also hold an additional array (see page 177, if you have the book, "Arrays of arrays") saving memory for the application.

My original method is to basically create a multi-dimensional array, collecting ALL data for each week, including those which are NIL. A ROUGH example is as follows:

arr(wkNo,DayNo,ReceiptType,)    'ReceiptType as integer
arr(wkNo,ExpenseType)    'ExpenseType as integer

As I mentioned, there will be a lot of memory wasted with this type of array as not every different type of expense will be encountered each week. (I.e. once the array has been created during run-time, there will be a fixed number of entries for each dimension)

Francesco's book mentions an array that can hold an additional array, a sub-array. Something that looks like arr(1)(2) for example.

Although I can roughly grasp the method in particular, I am trying to find out a way how I can create a "sub-array" to deal with the week by week expenses so that they can be stored as need be, but when there is no data to save, then no sub-array is created.

Sorry if the above sounds confusing, but I can't think of any better way to describe what's going on! Like I said, have a look at the attached form!

Multiple Arrays Linked By Their Index, Needs Sorting By Values Of One Of The Arrays
I have multiple arrays that I link by using a comon index..... One of the arrays is a final score. I need the score sorted by value and need the index values in that sorted order so that I can reference the other arrays with that index at the same time..... Any ideas

array example is....

mytext(X), mytext2(x), myscore(x)

Ill have about 30 instances of this and need to rank them by their scores and ba able to reference them by how they rank.
Dan

EXCEL CHARTS AND ARRAYS - WORKSHEET FUNCTIONS AND ARRAYS
I have two questions regarding arrays

1) is it possible to use an array for chart .value, rather than a range - ie I have array in which I have undertaken data processing and simply want to chart the data without having to pass it out back into a worksheet.

2) Can I use range methods on arrays, ie application.function.sum etc etc, on a column in an array - do I need to convert to range -if so how do I do that without writing data back to a worksheet ?


Many thnaks


adam cox

Memory Allocation - Arrays Vs UDT Embedded Arrays
Which will use less memory, a multidimensional array or the UDT which contains an embedded array??

1. MultiDimensional Arrays -- MDArray(10,10, 100)

OR

2. Array embedded in UDT

Dim UDTArray(100)

Type UDT
First As Integer
Second As Integer
UDTArray() As Single
End Type

Finding Row Of An Item In Arrays Of Arrays
I have an arrays of arrays, anarray with 2 rows and 3 columns. I need to know I want to find the row number of a certain item in the array, how can I do that: for simplification I am giving the contents of anarray:

anarray(1)(1) = "id1", anarray(1)(2) = "id2", anarray(1)(3) = 1
anarray(2)(1) = "id1", anarray(2)(2) = "id3", anarray(2)(3) = 2

Now if I want to find the row number of id2, how can I do that?

Dynamic Arrays Vs. Standard Arrays
Quote:Originally Posted by herilane1) What is the difference between declaring an array as an array, and declaring it as a variant? I.e. between
Dim a As String(2)
a(0) = "bla"
a(1) = "blaha"
a(2) = "eek"
and
Dim a As Variant
a = Array("bla", "blaha", "eek")
These are minor differences for VB, but can be a whole different ball of wax in the Excel environment.

Code:
Dim A as String(2) ' Doesn't work for me, I get a compile-time error
Dim B(2) as String ' An Array of Strings, 0..2 or 1..2 depending on Option Base
Dim C() as String ' A Dynamic Array of Strings
Dim D() ' A Dynamic Array of Variant
Dim E ' A Variant, which can easily wrap a Dynamic Array of Variant
So B is a standard Array while C&D are Dynamic Arrays requiring ReDim before being used. These are standard VB concepts. Case E can be ReDim'ed as well and thereby contain a Dynamic Array.

In many ways though, cases D and E are the most interesting. It is only these two situations -- either a Dynamic Array of Variants or a simple Variant -- that can be set to the value of a Range. For example:

Code:
Dim D() as Variant

D = Range("A1:E10") ' Note: NO Set here!!
This is a heck of a lot faster than looping through the cells to paste all the values one by one!

You can now access D(i,j) instead of Cells(i,j) to get the values. If you have to do a lot of looping, etc. you can actually assign the values of the Range to the Array, do the required math, and then pass the results back to the Range (if changes were made) faster than looping through the cells directly!

To assign the array back, you would use:

Code:
Range("A1:E10") = D
(Again, so Set!)

-- Mike

VB 6.0 Help. [2D Arrays, 1D Arrays, Selection Sort]
Hi all, new to the forums..

Basically, my Advanced Higher project is due in a week on thursday and well.. im screwed as it is. I have a couple of problems..

1: I need to sort my program on total race time, which should be held in a 1D array named total(1 to 5). I need to fill each element with the total lap times from 5 different people, eg total(1) should hold the sum of drivers(1,2 to 6). If you understand me...

2: Ive tried to sort the 2d array using a selection sort, but something has went wrong?

Here is the code ive used:


Code:
Option Explicit
Option Base 1

Dim Drivers(5, 6) As Variant
Dim highest As Integer
Dim lowest As Integer
Dim average As Integer
Dim total(5, 6) As Variant
Dim min As Single
Dim max As Single
Dim driver As Single
Dim time As Single
Dim sorted(5, 6) As Variant
Dim drive As Single






Private Sub cmdExit_Click(Index As Integer)
frmGoKartTimes.Hide
Unload frmGoKartTimes
frmStartup.Show
End Sub

Sub cmdHelp_Click(Index As Integer)
Dim help As String
help = MsgBox("Click on Start to enter names and times for a new race. Click on Results to see the winner of the race and various other statistics Or click on Personal Statistics to see a certain driver's Personal Statistics.")
End Sub



Private Sub cmdRun_Click(Index As Integer)
Dim counter As Integer
Dim message As String
Dim number As Integer
min = 0
max = 90
counter = 1
picSort.Cls

For driver = 1 To 5
For time = 1 To 6
If time = 1 Then
Drivers(driver, time) = InputBox("Please enter the driver's name.", "Drivers And Times")
End If
If counter < 26 And time <> 1 Then
message = "Enter Time - between "
number = validate_value(min, max, message)
Drivers(driver, time) = number
counter = counter + 1
End If

Next time
Next driver

Call Sort

End Sub

Private Sub Sort()
Dim minimum As Integer

For drive = 1 To 5
sorted(1, drive) = Drivers(1, drive)
Next drive

Dim placeholder As Integer
placeholder = 2
Dim person As Integer
For person = 1 To 5
minimum = 2
For driver = 1 To 5
For time = 3 To 6
If Drivers(driver, time) <= Drivers(driver, minimum) Then
minimum = time
End If
sorted(driver, placeholder) = Drivers(driver, minimum)
Next time
Next driver
placeholder = placeholder + 1
minimum = 999
Next person




For driver = 1 To 5
For time = 1 To 6
picSort.Print Tab(time * 10); sorted(driver, time);
Next time
Next driver



End Sub



Function validate_value(ByVal min, ByVal max, ByVal message) As Single
'Validate input to be integer in range min to max

'Dimension local variables
Dim number As Single

'Start loop

Do
number = Val(InputBox(message & min & " and " & max & " seconds", "Validate"))
If (number > max) Or (number < min) Or (number <> Int(number)) Then
message = "You must enter an integer between "
End If
Loop Until number >= min And number <= max And number = Int(number)
validate_value = number

End Function




Any help is appreciated,

Thanks,

-Comacchio

Combining Byte Arrays And Byte Arrays Wrapped In Variants
I need to combine two byte arrays under VB 5.0, say BArray1 and Barray2. They will be wrapped in Variants, ie: Var1 = BArray1 and Var2 = BArray2.

Do I accomplish this with a simple:

Var3 = Var1+Var2?

Can I then create a byte array by appending BArray2 to the end of BArray1, creating BArray3, and set it equal to Var3?

Dim BArray1,BArray2, BArray3 as Byte
Dim Var1, Var2, Var3 as Variant
Var1 = BArray1
Var2 = BArray2
Var3 = Var1+Var2 (Or would that be Var3 = Var1 & Var2?)

Alternately:

BArray3 = BArray1 + BArray 2 (or BArray1 & BArray2)
Var3 = BArray3

Any difference between combining the arrays first or combining the variants first?

I am wrapping the byte arrays in variants for two reasons. First, a function I am using requires the byte array to be wrapped in a variant. Second, I don't seem to be able to get a VB5.0 function to return a byte array. It won't take a function definition such as:

FunctionMine(cat as Variant) as Byte()

It will take:

FunctionMine(cat as Variant) as Byte

Since I can't return the entire byte array, I put it in a variant instead, which I eventually need anyhow. I simply hate to not be able to return a byte array from a function, particularly if I need to do so in order to be able to append one byte array to the end of another. Any help on how to append one variant containing a byte array to the end of another variant containing a byte array, with no null in between? Any help on how to first return a byte array from a function under VB 5.0, then how to append one byte array to another?

Finally, I would like to know why VB 5.0, when I attempt to place a byte array containing ASCI codes in a text box, puts the last letter of the byte array after a question mark if I attempt to put the byte array (wrapped in a variant) in a text box. If the byte array ends with integers instead of text, it just puts a question mark. Does this differing behavior make some sense?

Thanks.

Question On Arrays Of Arrays
Hi,
I have recently been exploring this concept of arrays of arrays in a VB book. According to the book an array can be stored in a variant variable where each item can be an array. It also says that using arrays of arrays it is dynamically possible to change rows and columns at the same time preserve the original array. Can anyone show me with an example code how is it possible (i.e. to declare an arrays of arrays and dynamically change rows and columns)? The book gave an example but I really did not understand it.

Tic-tac-toe With Arrays
I have to create this tic tac toe game for a class or mine and i'm having some trouble figuring out how to make it check for a winner. It has to look for 3 across, 3 down, or 3 diaganol. I attached what I have so far and everything is in an array. Any help would be appreciated. I am new at this so thanks in advance.

Arrays In DX7
I was wanting to how many image arrays can be loaded in DX7, is there a certain amount that can be used.

My first DX7 game and I have 4 image arrays and it don't appear to allow for a 5th. Must I create another DD-surface or is there a limit?

Thanks

Billy

Arrays
I'm making Guitar Hero in VB6 and I have two pictureboxes that loop down the screen. When a picturebox gets to the bottom of the screen, I call a function to reposition the new notes onto that picturebox. Now the problem is that for button pressing there is an array of shapes, so how can I code it to say "if any shape in the array has a .top equal to 1600 and you press enter then the shape.visible = False?
Thanks

Arrays
I have one ball array and i want to load more. how would i be able to do that. I have a timer thats loads the ball when i want it to but i don't know how. Any ideas

Help With Arrays
hey im new at vb and im making a sliding puzzle game, u know... how u have 1 - 8 and a blank square and u move em about until u get

1 2 3
4 5 6
7 8

well ive managed to (with my brothers help) make the numbers random but i dont know how to make it so when u click on a number above/below or left/right of the blank space move (or switch captions) with the blank space

eg above.. if i clicked on the 6 it'd become

1 2 3
4 5
7 8 6

but i have no idea how to do that... any ideas? ive added my game as an attachment...

How Do I Use Arrays?
Hey i was wondering how to use arrays
like a full example of how to use a single dimension array
and an example of a two dimensional array?

~

Help Arrays II
Thanks for the reply. I now attach my code.


I am currently programming a version of Tetris in VB. THe problem is to do with arrays. i have made the tetris "grid" as an array. I have programmed the code to cahnge the colour of the squares to show the blocks. HOWEVER it wont. there are no compiling errors, it just refuses to change the colour of the grid squares. HELP !

How Big Is TOO BIG For Arrays?
Hello,
Does anyone know the maximum number of characters permitted in an array?
Every time I go over about 15,000 characters, including spaces, over about 15 lines, and about forty strings per line. I get the message ‘expression too complex’. I have about seven consecutive arrays and My macro seems to run really slowly. Am I expecting too much from my project? I was wondering if whether I might be able to increase speed by :
·bunching all my arrays together;
·creating or opening up a file, and writing on it using my arrays to process text copied over into that file ?

Here’s some code :

Option Base0
tableau = Array( _
" string ", "replacement string ", " string ", "replacement string ", _ ‘This array will go on and on and on!! but is limited apparently to about 15,000 characters!!
"", " ")

Set myRange = Selection

For i = 0 To UBound(tableau) Step 2
With myRange.Find
.Forward = True
.Wrap = wdFindStop 'instead of wdFindAsk that prompts you to check each time
.Format = False
.MatchCase = False
.MatchWholeWord = False '!!
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
myRange.Find.Execute FindText:=tableau(i), ReplaceWith:=tableau(i + 1), Replace:=wdReplaceAll
Next i

I’d be really grateful (again) for any help anyone can give me.
Thanks

Can This Be Done (Regarding Arrays) ?
Hi,

This is regarding the use of arrays in VBA.

I find that in some other programming languages that I've used so far, when I call a procedure along with the respective array arguments (in the middle of a main program), I am able to use the arrays as an 'output' of the procedure, ... ie the procedure runs some statements and churns out some values which are then placed into the very array arguments which were passed into it, & when the control is returned to the main program, the arrays would have assumed the new values.


(an example in VB syntax ........ which can't actually work in VB though ..... just to make my point clearer)

******************************************************

Sub MainProgram ()

Dim TestArray(10,10)

Call TestProcedure ( TestArray() )

' ' At this point in time, TestArray(1,1) would have assumed the value
' ' of "Hello World!" .......... but in VB it doesn't work ........

End Sub
______________________________________

Sub TestProcedure ( ArrayName())

ArrayName (1,1) = "Hello World!"

End Sub

******************************************************

My problem is that I don't seem to be able to do this in VB/VBA. I'm not sure if it's anything to do with how I've declared the arrays or does VB just use some other methods to output the values into an array??

If it's possible, I would like to create a public array whereby in the middle of the program I am able to modify / initiate the array values which can be referred to in other different modules / procedures.

Anyone can help? Thanx a lot!!

Arrays
What I want to do is have a multi-dimensional array which I can access from various subs. I get told I can't declare an array as PUBLIC so what's the answer please?

Arrays..
HI i need some help about doing an Array for a VB Excel Form

Into a form I placed 12 checkboxes and 12 textboxes, at the moment that the user press the commandbutton I need to get which one is checked and which one doesnt in order to write into the textbox.

I know that can be done with (i) values, but always i get an error message

the actions who need to be done for all the checkboxes and textboxes are,



Code:
If CheckBox1.Value = True Then
Tag1.Text = Name & RefA
Else
Tag1.Text = ""
End If

If CheckBox2.Value = True Then
Tag2.Text = Name & RefB
Else
Tag2.Text = ""
End If
ETC....I want to do it all in one statement, like checkbox(i) and Tag(j)....defining a checkbox(i) sub, referring to all the Checkboxes, same for the Tag(j) to all the textboxes

Thanks for any comment about it.

Arrays
Hello,

I need to check the value of 56 cells.
So, I use an 1 dimensional array that contains all the cells.

The following code works fine.

Code:
Static arrControlevelden(1 To 56) As String

arrControlevelden(1) = "E20"
arrControlevelden(2) = "I20"
arrControlevelden(3) = "M20"
arrControlevelden(4) = "Q20"
arrControlevelden(5) = "U20"
arrControlevelden(6) = "Y20"
arrControlevelden(7) = "AC20
...

If I define the array in a different way (see below), vba gives an error.


Code:
Static arrControlevelden(1 To 56) As String

arrControlevelden = Array("E20", "I20", "M20", "Q20", "U20", "Y20", "AC20",...)

Can anyone tell me what I'm doing wrong?

Thanks

Help With Arrays
Hi,

I am so lost, please help. I need to learn arrays for a project I'm working on.

Lets say I have a range of cells "A1:C4" that have letters or numbers in them.
How do I make an array that countains these values? Further how can I get the contents of the cell "B2?" I just need to get a conceptual start. I think that using arrays my be the answer to my problem, but I need to know the basics to expiriment.

Thank You

Some Help With Arrays Please
Hi All

Please can someone help me with the following array problem, i have an
array of command buttons cmdDep(0) to cmdDep(6). The code below populates the cmdDep
button captions from the first 7 rows of a vsflexgrid, this works great.


Code:
Private Sub Form_Activate()
Dim i As Long
fgDep.Row = 0
For i = fgDep.Row To fgDep.Row + 6
cmdDep(i).Caption = fgDep.TextMatrix(i, 0)
cmdDep(i).Visible = True
Next
End Sub
I then want to re-populate the same cmdDep buttons but from the next set of 7 rows from the grid
but i get an "Element array 7 does not exist" i understand why, but can't seem to figure out how
to get it working. Please could someone assist me with this.


Code:
Private Sub cmdDownArrow_Click()
Dim n As Long
fgDep.Row = 7
For n = fgDep.Row To fgDep.Row + 6
cmdDep(n).Caption = fgDep.TextMatrix(n, 0)
cmdDep(n).Visible = True
Next
End Sub
Many thanks

VB Arrays
http://www.rogepost.com/n/8788325591

If you run it on VB you will see it works ok.
My problem is, two users can book the same seat. How can I fix this?

Need Help With Arrays
Hello, I am a grade 11 student taking computer science and we have a final project, and we chose to create an inventory program (for VB 6.0)
Our program has bikes, intBikes() Array, and the bikes are being put into the program by an inputbox, we have to have an "Add Bike(s)" Function, how can we possible add to an array, and continue from the highest number of that array.
What i mean is say u have 6 bikes inputted, so u would have intBike(1), intBike(2), etc. and when someone choses to add a bike how can I make it so that the array will continue from intBike(7) and not start over? Any help on even generally adding to an array would help, thanks!

Arrays :|
well im making a program that pass the array to a list combo... but the number that i put on the array it have to get from a textbox...


Dim sTestArray(1 To text1.text) As String

but can creat :S plz help i need this for my school project :P

Ty for the help

Arrays
hello again XD

once more i require assistance

i have the current code

load (sub Questions())

this code i used to open an array i have declared earlier (see XD Heelp thread) and it does not work, the load code i mean

so i was wondering if u could point me to the correct code to access a previously declared array, and any other mistakes in my syntax u may have picked up on


thanks

Arrays In Vb6
Hi guys,

I am so used to java staff, I now want to do something about vb 6 but I am struggling to get my arrays working,please find below is my small code that gives me "type mismatch" error:

dim docTypes(3)
dim y as integer
docTypes(3) = Array("tman", "thembani", "mavungu")

For y = LBound(docTypes) To UBound(docTypes) - 1
Debug.Print docTypes(y)
Debug.Print docTypes(Array(y))
Next y

I will appriciate any help, Please....

Thanks.

Tman

2D Arrays
I need some advice on using a 2D array or maybe I should use something else...

Basically, Ive got 3 lists. all 2 different types which are even but different for each list its like this

Private Type Moves
xAxis As Integer
yAxis As Integer
End Type
Private m_Stratergy() As Moves

I havnt added the 2d part yet..

But as you can see im using a type which contains 2 different bits of data...


Now how would i load all of my data into these arrays to start of with. I no I have to redim preserve it but i havnt done that with 2d's before, any help would be wicked.

Help With Arrays
Hi guys and gals I am in need of some help . I have a script that lists all the files in the TIF, it then takes each file and collelcts the last access date for that file. For each file i would like to place the filename and date in the array, i think it is like a multidimensional array. The whole idea is so that I can sort them later based on the date.

Problem is i am unsure of how to go about it, can someone please explain it to me. This is all i have so far


Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Clear the listbox
FoundFiles.Items.Clear()


If Extension1.Checked = True Then
Extension = Extension1.Text
ElseIf Extension2.Checked = True Then
Extension = Extension2.Text
ElseIf Extension3.Checked = True Then
Extension = Extension3.Text
ElseIf Extension4.Checked = True Then
Extension = Extension4.Text
End If


'Search all sub directories of the temporary internet folder
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
("C:Documents and SettingsOLYMADLocal SettingsTemporary Internet Files", _
FileIO.SearchOption.SearchAllSubDirectories, "*." & Extension)

' Create a file count
Dim FileCount
FileCount = FileCount + 1
Count.Text = "Total Number of Files Found = " & FileCount

' Add items to the listbox
FoundFiles.Items.Add(foundFile)

'Set Time as Last Accessed Time
Time = File.GetLastAccessTime(fileName)

Next

End Sub

Arrays...
It's me, yet again,

I'm trying to read a list of text objects into the text of a ButtonMenu. This is the code I'm presently using...

[vb]
Dim i As Integer, Ary(50) As String
Set ts = FSO.OpenTextFile("C:Links.dat", ForReading, False, TristateFalse)

For i = UBound(Ary) To LBound(Ary)
Toolbar1.Buttons(12).ButtonMenus.Add.Text = ts.ReadLine
Next i
ts.Close
Set ts = Nothing
[vb]

It's not working. What have I done wrong?

2D Arrays
I'm currently trying to create a program which uses a 2D array and despite trying to find information on it I am still lost.

I am creating a multiple choice game where when the user picks the right answer the array adds one and shows on the form the score they are now on.

I have done this with the following code,

Amount(0) = "0"
Amount(1) = "100"
Amount(2) = "200"
Amount(3) = "300"
Amount(4) = "400"
Amount(5) = "500"
Amount(6) = "600"
Amount(7) = "700"
Amount(8) = "800"
Amount(9) = "900"
Amount(10) = "1000"
Amount(11) = "2000"
Amount(12) = "3000"

Can anyone who knows anything about 2D arrays help me in turning what i've got into a 2D array?

Arrays In An Irc Bot
Hello,

I am currently working on an IRC bot, and what I am trying to do is have an Admin array which I can add and delete users to and from.

Example.

The array holds one value already by default, and that is "Blazin".

After connecting to the IRC, if I do the command, "!addadmin Nickname", it will add "Nickname" to the array. Also if I do "!removeadmin Nickname", it will remove "Nickname" from the array.

I am lost on how to do this, much help is appreciated.

Arrays.
Can some one PLEASE help me!!

I have an array which accepts 10 numbers. I now need to add the 10 numbers that the array contains and display them in a text box. Does anybody have any idea of how to do this??

Arrays In VBA
I have a Following Situation where I am getting stuck.


Code:
Dim arrData(0 To 40, 0 To 20) As Variant

I want to create the Above array such that I can ReDim to increase Column size as required but on following Code line I keep getting Error that Array is already Dimensioned. Any suggestion as to where I can look for Help or does any one know how to fix this ?


Code:
intCol = intCol + 1
ReDim Preserve arrData(0 to 40 , 0 To intCol )
Thanks in Advance,
Datta.

Help With Arrays
This may not be difficult but I am completely lost. Heres the situation.

I am building a program that will let a user enter a group of ID numbers into an array of text boxes. The user can enter 1 ID or up to 34 ID's. The 34 is an arbitrary number, it could be more or could be less.

Then I want the program to look at each text box in the array, and then go to a Crystal Report (using the OCX) and place that report in the que and print them.

If my text boxes were not an array I could simply loop through each and get the ID and authorize the report. I set the text boxes up as an array, thinking that would save a lot of code as I looped through the entries but...I can't figure out how to do the loop using the array and I can't figure out how to get the total number of filled in text boxes so that I can do a "do until" loop.

Can anyone give me some suggestions?

Arrays
hey

i was wondering, if i dim a dynamic array like so:


Code:
dim strArray() as string
then how could i populate, say, the first item of this array?

because i checked msdn, and it says if you try things like:

Code:
strArray(0) = "hello world"
it will return error 9 :s

furthermore,

if i have a dynamic array like this:
strArray(0) = "hello world"
strArray(1) = ""
strArray(2) = ""

and i add another item to strArray() like so:
strArray(Ubound(strArray())) = "hello 2"
will this add "hello 2" in strArray(1) or will it add it in strArray(3) ?

thx

2 D Arrays
there is an two d array having some string on its 0,0th element
like

"abc",123
"def",124
"ghi",123



i want all duplicates(checking on second subscript which is in that case happens to be 123 , 124, 123) to appear once only in final array

with contents of which are for duplicates value

so my final array shd look like

"abc:ghi ",123
"def",124



pls help me solve this

this looked lke kids play to me ...bt sure is tuff

pls help me guys if ne one can help me

Arrays
OK. Here's the thing. I have a multiple Winsock control sitting on my form. I want to go through each of the connections, establish whether or not the State is equal to sckConnected, and if it is, store it in an array.

The problem is that when you define an array, you of course need a constant string, not a variable. So I need to be able to make the array IPs() have exactly as many strings within it as there are connections to Winsock.

How can I do this?

Thanks,
Jared

Help With Arrays!!!
Hello, i need some help with this assignment.....

Here is the synopsis:

Write a function that accepts two arrays and a String. The first array, dtePurchaseDates, should be an array of dates. The second array, decSaleAmount, should be an array of Decimals. Each array should contain 100 items. The String strMonth should represent the month whose total sales will be returned from the function. The function should loop through the arrays and total the sales of the month indicated and return the total.


_______________________________________________
my code thus far....

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare arrays and variables
Dim dtePurchaseDates(99) As Date
Dim decSaleAmount(99) As Decimal
Dim strMonth As String, strSearch As String
Dim intStep As Integer, intTotal As Integer

'Initialize variables that need to be intialized
intTotal = 0
intStep = 0


For intStep = 0 To 99
If (strSearch = dtePurchaseDates(intStep)) Then
intTotal += (strMonth)
End If


Next intStep


_________________________________________________

thanks
mystic

Arrays In VB6
ok ppl i'm back

i've looked on the net and in books but i cant seem 2 get my head around arrays.

my form has text boxes for input, all the information has to be entered, then the calculations need 2 be done.

once everything is displayed in the boxes, the save button will be enabled.

when the save button is pressed, this will save to a file e.g. 'wages.txt'

i must be able to add multipul records and move between them, e.g back n forwards

it all must corispond, e.g,

fred, 25 well road, 10 sheep, £40 per sheep, total £400
jim, 182 fall lane, 20 cows, £100 per cow, total £2000
alex, 78 penn road, 5 monkeys, £70 per monkey, total £350

i can do this in a database and link it up, but i need 2 know how 2 use arrays or i'll never learn.

hopefuly there is sum1 out there 2 help me :'(

i'd be very greatful if sum1 would take a lil time out 2 help me as i'm new to vb and to get nefurther i really need help with this

thanx again for any help

Help With Arrays
I have written the code below so far. I have 9 command buttons that are set up as an array at run time, captioned 1-9. As I click each button it outputs to a label like it would if you used a computer calculator. I am missing something with the variable because it only works for the first click and then each time it starts fresh with the next caption. If I press 2, I get 2, but then when I want to concenate the next (say 3), I get 33, rather than 23. When I cycle through in break mode it stops after each click. How do I get the variable to hold the previous value in memory and then when the next button is pushed concenate it to the first as either another variable or a new version of the same? Thank you


Private Sub cmd_Click(Index As Integer)
Static Key As Integer
If Label1.Caption = "" Then
Key = cmd(Index).Caption

Else
Key = Key & cmd(Index).Caption

Label1.Caption = Key

End If

End Sub

Need Help With Arrays!!!
Hi, I am just wondering if someone could give me a practical explanation of what an array is. I have read a number of books and copied code but I just can’t get the concept together enough so that I can improvise with it in my own programs. If someone has a simple way to explain this it would be much appreciated. It would also really help if I had a solid example to try out.
To be honest I would probably like to ask the same question about loops because I'm not sure I understand loops well either. I know this is rather fundamental stuff and I have studied it but I was hoping that someone who may have at one time struggled with this may have a good way to explain it.

Thanks in advance!

Please Help!!! Arrays
I have to modify an application so that it uses two one-dimensional arrays instead of two two-dimensional arrays to store the FWT tax tables. I keep getting an error in my AfterUpdate sub procedure and I have no idea how to fix it. Im new to visual basic so if anyone could help me I would appreciate it.

Arrays
I fairly new to the programming scene and am a high school student. I am i bit confused with the arrays. I understand single dimension arrays except for dynamic arrays and its moving limits. I really need some help with multidimension arrays and arrays of records. I know you declare them something like this.

Dim Array(20,20)

But thats about all i know. I also cant seem to get arrays to be public as it says can not make public in an object module any help??

Arrays, From 10 To 1????
I wished to have an array which is called BoxNo(Index). Now in this array it would hold two values, the x position of the box and the y position.....How would I decalre this array, and then how could I use it so that if another routine provides a set of x and y values, it can relate to a certain box number ....ie. BoxNo(1) = (1, 1) where the routine returns the values x = 1, y = 1 and then make this related to a certain image which is an image on the screen.


this is what i have so far

Code:
Private Sub Command1_Click()
Static BoxXY(1 To 10, 1 To 10)
Dim x As Integer
Dim y As Integer
Index = 0

For x = 1 To 10
For y = 10 To 1
Index = Index + 1
BoxXY(x, y) = Index
Next y
Next x

Text1.Text = BoxXY(3, 4)

End Sub


But the text box displays no value...

ARRAYS
Hello to all,

I have a listview which is first populated from the backend and filled the listview, then I also store the entire
listview data into an array. I also have a combo box which I also populated with unique departments from the listview. The Dept are in column 4 of the listview.

I got some filtering to do. I need the combo box and the other filters to worked together.

----------------
LookUp Dept: ** combo box with unique values **
----------------
Example

<Select All>
50
60
70
80


[x]Wait [ ] Respond [ ] List All (control arrays)


Here is what I am looking for.

If choose <Select All> and check off either Wait or Respond or List All
should filter the listview which I already stored in an array and show me the filtering recordset.

If choose 80 and check off either Wait or Respond or List All
should filter the listview which I already stored in an array.

and so on.

My code is not working well with the <Select All>. Its does notthing.



Code:
Private Sub CheckOptCaseStatus_Click(Index as integer)
'*************************************************************************
'Purpose: Depend upon what the user choose, we assigned the filter
'
'*************************************************************************
Dim intSubLen As Integer
Dim intCtlLen As Integer
Dim intOCtlLen As Integer
Dim blnSent As Boolean
Dim blnWait As Boolean
Dim blnAdd As Boolean
Dim itmX As ListItem
Dim blnAll As Boolean
Dim intArrLen As Integer
Dim intRespRedColor As Integer


Screen.MousePointer = vbHourglass
Call SplashDialog_Set(True, "Refreshing the Working List ........")
For intCtlLen = 0 To Me.CheckOptCaseStatus.Count - 1
If Me.CheckOptCaseStatus(intCtlLen).value Then
Select Case intCtlLen
Case 1
blnSent = True
Case 0
blnWait = True
Case 2
blnAll = True
End Select
End If
Next intCtlLen
'here we test if its an array exist and then continue
If IsArray(itmWitness) Then
'If there are records, then continue
If UBound(itmWitness) > 0 Then
Me.LvwWorkingList.ListItems.Clear
'Reload the listview and populate the items from the array.
'here we loop thru the temporary array(itmWITNESS) using the lbound and ubound
'and set the criteria's we want
For intArrLen = LBound(itmWitness) To UBound(itmWitness)
blnAdd = False
If Not blnAll Then
If UCase(Trim(itmWitness(intArrLen).ListSubItems(4))) = "RESPONDED" And blnSent Then blnAdd = True
If UCase(Trim(itmWitness(intArrLen).ListSubItems(4))) = "WAITING" And blnWait Then blnAdd = True

Else
blnAdd = True
End If

If blnAdd Then
Set itmX = Me.LvwWorkingList.ListItems.Add(, itmWitness(intArrLen).Key, itmWitness(intArrLen).text)
For intSubLen = 1 To itmWitness(intArrLen).ListSubItems.Count
itmX.SubItems(intSubLen) = itmWitness(intArrLen).ListSubItems(intSubLen)
If blnAll Then
For intRespRedColor = 1 To itmX.ListSubItems.Count
If itmX.SubItems(4) = "Responded" Then
itmX.ForeColor = vbRed
itmX.ListSubItems(intRespRedColor).ForeColor = vbRed
End If
Next intRespRedColor
End If
Next intSubLen
Set itmX = Nothing
End If
Me.lblWorkingLstCnt = "Filtered Case Count:" & Space(2) & Me.LvwWorkingList.ListItems.Count
Next intArrLen
End If
End If
Call SplashDialog_Set(False, "Finish Loading ........")
Screen.MousePointer = vbNormal
End Sub

thanks for any help

Arrays
Is there a quick way to set the value of every element in an array. For instance I want array a() to have the values 1,1000,1000,1000,1,1000,1000,1000,1 or something to that effect. Is there something like:

a = /1,1000,1000,1000,1,1000,1000,1000,1/

The data may not necessarily be cyclic and I don't want to have to set each value individually.

Copyright © 2005-08 www.BigResource.com, All rights reserved