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




I Need Help Looping Through An Array. [SOLVED]


Take a look at this function.


VB Code:
Private Function ColorServerMessageLines()    Dim strArray As String    strArray = Split(rtbServerMessages.Text, vbNewLine)    For i = 0 To strArray - 1        If Left$(strArray(i), 6) = "SYSTEM" Then            rtbServerMessages.SelStart = 0            rtbServerMessages.SelLength = Len(strArray(i))            rtbServerMessages.SelColor = vbDarkGreen        ElseIf Left$(strArray(i), 5) = "ERROR" Then            rtbServerMessages.SelStart = 0            rtbServerMessages.SelLength = Len(strArray(i))            rtbServerMessages.SelColor = vbDarkRed        End If    Next iEnd Function


What this code is *supposed to* do is split the contents of my textbox into an array, using the newline character as a delimiter. It should then loop through each of the resulting elements, searching for a specific string at the beginning, and coloring the different lines accordingly. However, when I run the code, I get this error.

Expected: Array

Shouldn't the Split function have already made it an array? What corrections do I need to make to get this to work right?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Looping Though A Listview (solved)
cant seem to find a tutorial on what im trying to achive.

I have a cost value at the end of each line in a listview, i want to loop thought the listview adding the value to a running total as i go.

Listviews confuse me somtimes

*solved* How To Stop Looping?
Hi this code finds what i want then keeps going..... how to stop when found?Code:Set rs = New ADODB.Recordset 'this will be the rs
Dim strSQL As String 'this the source
strSQL = "Select REG, ID From ZZ WHERE ID = 1" 'Get all records from tblExample
    rs.Open strSQL, oConnection, adOpenStatic, adLockBatchOptimistic, adCmdText
    Do Until rs.EOF
        If (rs("REG") = FTest.txtEnigma) Then
            FTest.Visible = False
            Form1.Visible = True
        ElseIf (rs("REG") <> FTest.txtEnigma) Then
            Form1.Visible = False
            FTest.Visible = True
        End If
    DoEvents
    rs.MoveNext
    
    Loop
    rs.Close 'Close the recordset never leave it open!
    Set rs = Nothing 'clear the rs variable
Or ZZ.REG = null aswell?
I tried to writeCode: strSQL = "Select REG, ID From ZZ WHERE ID = 1" 'Get but to no Avail....hmmmmmm

---------------------------------------------------------------------------------------------------------------------------------
Todays random quote: I am still determined to be cheerful and happy, in whatever situation I may be; for I have also learned from experience that the greater part of our happiness or misery depends upon our dispositions, and not upon our circumstances.

Martha Washington (1732 - 1802)
---------------------------------------------------------------------------------------------------------------------------------

Edited by - Hopeless on 2/29/2004 7:01:59 PM

Looping Through Windows Control [SOLVED]
Good day.

I got a question here. Is it possible for me to use a foreach loop to iterate through all the controls in a form ? Something like control(0), control(1) ....... ?

I need this as I wish to write a control that can handle the event of resizing the form.

Thanks a lot.

SonicWave

Looping Though An Array
Hi,

I need help cycling through the below array using the intGroupNumber. I want to process all the "1" first and so on. I know I need a "For...Next" loop.

1, joe
1, john
2, henry
2, bob
3, lisa


------------------------------------------------------------------------------
Private Type EmployeeStructure
intGroupNumber Integer
strName As String
End Type


Dim EmployeeRecord ( ) As EmployeeStructure
---------------------------------------------------------------------------

Would this Work? Thanks
"For EmployeeRecord.intGroupNumber = 1 to 3"

Looping Array?
ok i'm making a project thats inputs and outputs are in binary. what i'm hoping to do is somthing like when a 1 is present change from 1 picture to a second one(so only 2 pictures). I'm only using 6 digits(example: 101100)



Example say the x's and o's are pictures.

Input: 001110

Output:
0
0
x
x
x
0

The array is Image1(0) - Image(5)

Thanks in advance!!!

Looping Through An Array??
Hi folks,

I have the following codes. It works fine. But I want to revise the code in the Private Sub cmdDisplay_Click() so that I use a loop and an if statment within it. I am kinda stuck. How will you implement the nested if statements with just a loop and an if statement inside of it.
The loop, loops through the intPoints array. Thanks


Code:

Option Explicit
Dim intPoints(1 To 5) As Integer
Dim strGrades(1 To 5) As String

Private Sub cmdDisplay_Click()
Dim intPointFromTextBox As Integer
Dim intNum As Integer

intPointFromTextBox = Val(txtPoints)

If intPointFromTextBox <= 299 Then
    lblGrade.Caption = strGrades(1)
Else
    If intPointFromTextBox <= 349 Then
        lblGrade.Caption = strGrades(2)
    Else
        If intPointFromTextBox <= 399 Then
            lblGrade.Caption = strGrades(3)
        Else
            If intPointFromTextBox <= 449 Then
                lblGrade.Caption = strGrades(4)
            Else
                If intPointFromTextBox <= 500 Then
                    lblGrade.Caption = strGrades(5)
                End If
            End If
        End If
    End If
End If
End Sub

Private Sub cmdExit_Click()
    Unload frmGrade
End Sub

Private Sub cmdPrint_Click()
    PrintForm
End Sub

Private Sub Form_Load()
    frmGrade.Top = (Screen.Height - frmGrade.Height) / 4
    frmGrade.Left = (Screen.Width - frmGrade.Width) / 2
    
    strGrades(1) = "F"
    strGrades(2) = "D"
    strGrades(3) = "C"
    strGrades(4) = "B"
    strGrades(5) = "A"
    
    intPoints(1) = 0
    intPoints(2) = 300
    intPoints(3) = 350
    intPoints(4) = 400
    intPoints(5) = 450
    
End Sub

Looping Through Array Names??
I have 100 arrays that i need to pass to a function. Obviously i'd rather not make 100 seperate calls. The arrays are named ArrayA1 to ArrayJ10:


Code:
For a = 1 To 10
For b = 1 To 10

Select Case a
Case 1: K = "A"
Case 2: K = "B"
Case 3: K = "C"
Case 4: K = "D"
Case 5: K = "E"
Case 6: K = "F"
Case 7: K = "G"
Case 8: K = "H"
Case 9: K = "I"
Case 10: K = "J"
End Select

Temp = "Array" & K & b

call sort(temp())

Next b
Next a
This makes a string that is the same as the array names but obiviously my function is expecting an array and not a string so it will cause an error. Anyone got any ideas how i can make this work??

Looping Through Each Array - Simple!
Hi everyone,

I have an array which has various subvalues and i'd like to be able to loop through each group in the array (from "0" to the largest value in the array). This it probably very simple to do but i can't get my head around it! :-D

Cheers!
Matt

Need Help With Looping Through Control Array
Hi, I'm new to this so please be patient. In my application I've about 20 questions. Right now I've got them hard-coded, but I'd like to make the code a little less bloated by incorporating control arrays and loops. I have several questions per control type. For example, I have 4 questions which use textboxes, 5 that use radio buttons, etc. I'd like to create a control array for each question type. Here is my puny attempt at creating a control array for the 4 textbox questions. When the user clicks on the "next question" button, I'd like the next question and textbox to appear. However, I don't know how to stop the looping process at each textbox, so that the next question appears, waiting for the user to hit the next button associated with that question, as opposed to the last question at the end of the loop appearing (right now when the "next" button from the first textbox question is clicked, the loop goes all the way to the last question.

Seems one way of dealing this woud be to put the procedure within another procedure, but I wouldn't know where to start...

I hope I've made myself clear here. Can anyone help?

Private Sub NextButton_Click(Index As Integer)
Dim i As Integer
For i = 0 To 2
NExtButton(i).Visible = False
LabelTextbox(i).Visible = False
NextButton(i + 1).Visible = True
LabelTextbox(i + 1).Visible = True
Next i

End Sub

Looping An Array Element ?
For i = 1 To UBound(myarray)
For lCtr = 1 To Len(myArray(i)) Step 2
totalbytes = totalbytes + Val("&H" & Mid(myArray(i), lCtr, 2))
MsgBox totbytes
Next i


With this loop should it increment each element like this :

myArray(1)
myArray(2)
my Array(3)....and so on

I dont know why but if I enter the element number manually then the function works, but if use a loop to change myArray(i) and cycle through elements 1 - 6 the function works for myArray(1) but then the function fails to add the bytes correctly from elements 2 - 6.

btw - the functions adds up every 2 bytes and returns the total in decimal.

Like I say it only works if I manually change myArray(i).

Any help appreciated

Looping Multidimention Array (plz Help)
hi there, i have a snag.

i have a 2 arrays

dim array1(3) as integer
dim array2(3) as integer

and i third array used for storing

dim array3(15) as integer

i basically want to loop through the top 2 array (so like im looping through a 4x4 grid) and store the 16 values in the third array array3(15)

how might i wrote the code for this please ?

Problem Looping Through Array
I have a treeview that has it's nodes loaded from a database.
The following list is the names of the nodes and their Keys.

I have stripped the key from the end to see if the string part of the array element matches the string retrieved from the registry.
This works and when I use the Debug.Print for "NodesKey" as it is being stored into the array, I get what I expect, which is:
API P1Databases P2Databases Access C3Databases Excel C4Databases Text Files C5Modules P6Notes P7Notes API C8Notes Databases C9Notes Functions C10Notes Modules C11Notes Subs C12Notes VB General C13Notes VBA C14SQL P15VB Code P16VB Code Collections C17VB Code Forms C18VB Code Functions C19VB Code Subs C20VB Code UDT C21VBA Code P22VBA Code Access C23VBA Code Excel C24
The problem I am having, is when I loop through to check which array element matches the registry value, it goes from element number 3 (Database Acces) straight to element number 6 (Modules)
I cannot for the lfe of me work out why this is happening.

Below is the list from the immediate window.
As you can see, it clearly has all the elements expected in the array down to C24,
but after that is what is happening in the loop.
API P1Databases P2Databases Access C3Databases Excel C4Databases Text Files C5Modules P6Notes P7Notes API C8Notes Databases C9Notes Functions C10Notes Modules C11Notes Subs C12Notes VB General C13Notes VBA C14SQL P15VB Code P16VB Code Collections C17VB Code Forms C18VB Code Functions C19VB Code Subs C20VB Code UDT C21VBA Code P22VBA Code Access C23VBA Code Excel C24
API P1Databases P2Databases Access C3Modules P6Notes P7SQL P15VB Code P16VBA Code P22VBA Code Excel C24
Items 1 - 24 are the correct elements for the array.
25 - 33 are the elements being looped through in the following code. the rest of the elements are empty! I cannot see why the elements are now empty!
My Code:

vb Code:
With tvwCode    Do While Not rs.EOF        'check if node is same or different        If strNodeParent <> rs.Fields("tvwNodes").Value Then            'if different, it's a new parent node            strNodeParent = rs.Fields("tvwNodes").Value            'add 1 to the key            lngNodeParent = lngNodeParent + 1            'update key number if previous Parent node had children            If lngNodeParent <= lngNodeChild Then lngNodeParent = lngNodeChild + 1            'add the new node, with the new key and it's name            .Nodes.Add , , "P" & CStr(lngNodeParent), strNodeParent, "Folder Closed"            If PCtr = 0 Then                strParent(PCtr) = strNodeParent                NodesKey(KeyCtr) = strNodeParent & " P" & CStr(lngNodeParent)                Debug.Print NodesKey(KeyCtr)                PCtr = PCtr + 1                KeyCtr = KeyCtr + 1            Else                ReDim Preserve strParent(UBound(strParent) + 1)                strParent(PCtr) = strNodeParent                ReDim Preserve NodesKey(UBound(NodesKey) + 1)                NodesKey(KeyCtr) = strNodeParent & " P" & CStr(lngNodeParent)                Debug.Print NodesKey(KeyCtr)                PCtr = PCtr + 1                KeyCtr = KeyCtr + 1            End If        End If         'if needed, add the child        'check if there are any child nodes -        'if Fields is "" then no new child nodes        'move on to next parent node        If strNodeChild <> rs.Fields("tvwChildNodes").Value & "" Then            'if Fields is not empty - add new child node            strNodeChild = rs.Fields("tvwChildNodes").Value & ""                If strNodeChild <> "" Then  '(dont add Null/blank child nodes)                    'add 1 to the key                    lngNodeChild = lngNodeChild + 1                    'if necessary add 1 to make number unique                    If lngNodeChild <= lngNodeParent Then lngNodeChild = lngNodeParent + 1                    'add the new child node with the path of the parent node                    .Nodes.Add "P" & CStr(lngNodeParent), tvwChild, "C" & CStr(lngNodeChild), strNodeChild, "Folder Closed"                    If CCtr = 0 Then                        strChild(CCtr) = strNodeParent & " " & strNodeChild                        If KeyCtr > 0 Then                            ReDim Preserve NodesKey(UBound(NodesKey) + 1)                            NodesKey(KeyCtr) = strNodeParent & " " & strNodeChild & " " & "C" & CStr(lngNodeChild)                            Debug.Print NodesKey(KeyCtr)                            KeyCtr = KeyCtr + 1                        Else                            NodesKey(KeyCtr) = strNodeParent & " " & strNodeChild & " " & "C" & CStr(lngNodeChild)                            Debug.Print NodesKey(KeyCtr)                            KeyCtr = KeyCtr + 1                        End If                        CCtr = CCtr + 1                    Else                        ReDim Preserve strChild(UBound(strChild) + 1)                        strChild(CCtr) = strNodeParent & " " & strNodeChild                        ReDim Preserve NodesKey(UBound(NodesKey) + 1)                        NodesKey(KeyCtr) = strNodeParent & " " & strNodeChild & " " & "C" & CStr(lngNodeChild)                        Debug.Print NodesKey(KeyCtr)                        CCtr = CCtr + 1                    End If                End If        End If       '(grand-child is similar to child, but you dont need to store the text/key!)         rs.MoveNext    LoopEnd With'close the recordsetrs.CloseSet rs = Nothing'if not needed after this, close the connection here toocn.Close For CCtr = 0 To UBound(NodesKey)Debug.Print NodesKey(CCtr)Next '===========================================================' Show selected category in treeview (from registry)''loop through KeyCtr() to find the correct Start Option'===========================================================StartOpt = GetRegistryStr(hkeyLOCAL_MACHINE, strSubKey, "StartOption") Dim X As LongDim Pos As LongDim tmpStr As StringDim tmpKey As String For X = 0 To UBound(NodesKey)Debug.Print NodesKey(X)    Pos = InStrRev(NodesKey(X), " ", Len(NodesKey(X)))    tmpStr = Trim(Left(NodesKey(X), Pos))    If StartOpt = tmpStr Then        tmpKey = Right(NodesKey(X), (Len(NodesKey(X)) - Pos))        tvwCode.Nodes(tmpKey).Selected = True        Exit For    End IfNext

Looping Thru An Assigned Array
sorry if this is too basic but i cant seems to get it to work..


let say i created an array

X= array(2,20,100,400)

how am i suppose to write it so that
the first is X=2 , 2nd is x=20 3rd is X=400??

Error Looping Through Array
I have this program where I loop through an array and get information through inputboxes. (see code below) My question is, how can I compute the average check (c) and the average deposit (d)? Every time I try to do this within the loop, I get a compiler error.

Dim T(20, 4) As Variant
Dim n As Integer
Dim i As Integer
Dim check As Variant, deposit As Variant
begindate = InputBox("What date do you want to begin recording transactions?")
enddate = InputBox("What date do you want to finish recording transactions?")
n = DateDiff("d", begindate, enddate)
For i = 1 To n
T(i, 0) = InputBox("What is the transaction number?")
Picture1.Print ("The transaction # is "); T(i, 0)
T(i, 1) = InputBox("What is the amount?")
Picture1.Print ("The amount is "); Format(T(i, 1), "$0.00")
T(i, 2) = InputBox("What is the type of the transaction? (C for check, D for deposit)")
Picture1.Print ("The type is "); T(i, 2)
T(i, 3) = InputBox("What is the date of the transaction?")
Picture1.Print ("The date is "); T(i, 3)
Next i

Problem Looping Through Array
I have a treeview that has it's nodes loaded from a database.
The following list is the names of the nodes and their Keys.

I have stripped the key from the end to see if the string part of the array element
matches the string retrieved from the registry.
this works and when I use the Debug.Print for "NodesKey" I get what I expect, which is:

API P1
Databases P2
Databases Access C3
Databases Excel C4
Databases Text Files C5
Modules P6
Notes P7
Notes API C8
Notes Databases C9
Notes Functions C10
Notes Modules C11
Notes Subs C12
Notes VB General C13
Notes VBA C14
SQL P15
VB Code P16
VB Code Collections C17
VB Code Forms C18
VB Code Functions C19
VB Code Subs C20
VB Code UDT C21
VBA Code P22
VBA Code Access C23
VBA Code Excel C24

The problem I am having, is when I loop through to check which array element matches the registry value, it goes from element number 3 (Database Acces) straight to element number 6 "Modules"
I cannot for the lfe of me work out why this is happening.

My Code:
Code:Dim X As Long
Dim Pos As Long
Dim tmpStr As String
Dim tmpKey As String

For X = 0 To UBound(NodesKey)
Debug.Print NodesKey(X)
    Pos = InStrRev(NodesKey(X), " ", Len(NodesKey(X)))
    tmpStr = Trim(Left(NodesKey(X), Pos))
    If StartOpt = tmpStr Then
        tmpKey = Right(NodesKey(X), (Len(NodesKey(X)) - Pos))
        tvwCode.Nodes(tmpKey).Selected = True
        Exit For
    End If
Next

EDIT
I have just run this again and below is the list from the immediate window.
As you can see, it clearly has all the elements expected in the array down to C24,
but after that is what is happening in the loop, code above.

This is very erratic!

API P1
Databases P2
Databases Access C3
Databases Excel C4
Databases Text Files C5
Modules P6
Notes P7
Notes API C8
Notes Databases C9
Notes Functions C10
Notes Modules C11
Notes Subs C12
Notes VB General C13
Notes VBA C14
SQL P15
VB Code P16
VB Code Collections C17
VB Code Forms C18
VB Code Functions C19
VB Code Subs C20
VB Code UDT C21
VBA Code P22
VBA Code Access C23
VBA Code Excel C24
API P1
Databases P2
Databases Access C3
Modules P6
Notes P7
SQL P15
VB Code P16
VBA Code P22
VBA Code Excel C24


--------------------------------------------------------------------------------
aikidokid

We all have to start somewhere .... I think I'm at somewhere

Edited by - aikidokid on 3/15/2007 6:35:47 AM

Calculation While Looping Array
I have a csv file which contains the following:

Machine;time;date;alarm;descrip
FEEDER10 ; 15:10:15;07/23/04 ; Alarm ; N ; 10 Refill Timeout;
FEEDER11 ; 15:10:15;07/23/04 ; Alarm ; Y ; 11 Refill Timeout;
FEEDER11 ; 15:10:16;07/23/04 ; Alarm ; N ; 11 Refill Timeout;

What I need to happen is where the machine types are the same I need to calculate the time difference. Such as

Machine;time;date;alarm;descrip;diff
FEEDER10 ; 15:10:15;07/23/04 ; Alarm ; N ; 10 Refill Timeout; 0
FEEDER11 ; 15:10:15;07/23/04 ; Alarm ; Y ; 11 Refill Timeout; 0
FEEDER11 ; 15:10:16;07/23/04 ; Alarm ; N ; 11 Refill Timeout; 01

Here is what I'm thinking, which is giving a type mismatch error.

Dim test() As String
Dim testcnt As Integer
Dim j As Integer
Dim entries As String
Dim stime As String

Open "c:alarmlog.csv" For Input As #1

' read line by line to array
Do While Not EOF(1)
ReDim Preserve test(testcnt)

Line Input #1, test(testcnt)

testcnt = testcnt + 1
Loop

Close #1

entries = "100"


For j = 1 To entries - 1
If test(i)(j + 1) = test(i)(j + 2) Then
stime = test(i)(j + 2) - test(i)(j + 1)
End If

End Sub

Thanks Guys.

Feetching In Array Without Looping Throught It
Wonder if there a way to find certain subscript in a array that match my target value. (find the scriptscript that hold the correct player name). Since it a online server and the array will become increasly bigger, would there a more efficient way than someting like this.


Code:
for x = 0 to ubound(PlayerNickname)
if PlayerNickname(x) = TargetNickName then
Subscript = x
goto LABEL_QUIT_FOR_LOOP
end if
next x

LABEL_QUIT_FOR_LOOP:
Just wondering because every player will request data from a array in the server often and finding a efficient way is really critical to making sure the game wont start laging.

How To Store The Values Into Array While Looping
i need to store the value into array while loop is executing.this is my code.there iere will be no of values node list . i need to store the BYTES,NUMBERS and CONTENT into 3 different arrays namely bytesval,numbers and content while looping .pls help me to solve the problem
Code:
Private Sub Command1_Click()
Dim objDoc As MSXML2.DOMDocument
Dim objNodeList As IXMLDOMNodeList
Dim objNode As IXMLDOMNode
Dim bytesval() As Long
Dim numbers() As Integer
Dim content() As String
Set objDoc = New MSXML2.DOMDocument
objDoc.async = False
objDoc.Load "c:
zb3.nzb"

'Return all the segment elements
Set objNodeList = objDoc.selectNodes("//segment")
MsgBox objNodeList.length
ReDim bytesval(1 To objNodeList.length)
ReDim numbers(1 To objNodeList.length)
ReDim content(1 To objNodeList.length)
For Each objNode In objNodeList
bytesval() = objNode.Attributes.getNamedItem("bytes").Text
numbers() = objNode.Attributes.getNamedItem("number").Text
content() = objNode.Text
Next objNode

Set objNode = Nothing
Set objNodeList = Nothing
Set objDoc = Nothing

End Sub

Searching An Array For A String.. Without Looping
hey, was wondering if there is a way to check if a string is within an array, without looping through every entry in the array..

InStr([start, ]string1, string2[, compare]) works for strings..

but what about arrays???

i have array
strName (is a variant, not sure of how many will be in the array)

need to find strReqName if its in the strName

Looping Thru An Array, But ReDim In The Loop?
Hi Gang,

I'm looping through an array, using UBound as the upper limit of the loop, thus:


VB Code:
For myCount = 0 to UBound(myArray) - 1'  do some stuffNext


No prob so far.

Then I realised I needed to grown the array under certain circs, inside the loop thus:


VB Code:
For myCount = 0 to UBound(myArray) - 1'  do some stuff'Redim Preserve myArray(somevalue)'Next


Now the loop doesn't continue to the new end of the array; it still stops at the original end. Even tho' in step mode, if I park the mouse over the For stmt, which shows the UBound has increased, VB seems to have an internal representation of the For..Next's outer limit which it doesn't update.

I've worked around in a way I think is a bit ugly... set the loop's outer limit to be bigger than I expect and then check if I go past the end of the array, thus:


VB Code:
For myCount = 0 to 50      '50 > largest expected valueIf myCount > UBound(myArray) Then Exit For''  do some stuff'Redim Preserve myArray(somevalue)'Next


Any one got any better ideas please?

Array Elements To String Without Looping
'Let's say we got:

Dim MyArray(3) as String
MyArray(0) = "A"
MyArray(1) = "B"
MyArray(2) = "C"
MyArray(3) = "D"

'And we want to have One string "ABCD"

'this looks slow and clock cycles hungry

For i = 0 to ubound(MyArray)
MyString = MyString & MyArray(i)
next i

Is there a faster method ?

thank you

Looping Through Elements In Multidimensional Array
Hi,

I have a multidimensional array:
Code:

Dim myArray(1, 2) As Variant
    
    myArray(0, 0) = "string1"
    myArray(1, 0) = 5
    myArray(0, 1) = "string2"
    myArray(1, 1) = 50
    myArray(0, 2) = "string3"
    myArray(1, 2) = 8



I need to loop through the first dimension and extract all elements.

What is the best way to do that?

Thanks

User Defined Type, Array, Looping
Hi,

Private Type ScheduleStructure
lngNum As Long '1 - 3
strName As String
lngClass As Long '1-3
End Type

Dim udtFRecord ( ) As ScheduleStructure
Dim udtCRecord ( ) As ScheduleStructure


I have read a squential file into a user defined Type and and passed it into an array.Each lngNum has its own different class. I need some help on how to loop through lngNum and use a select statment to choose a class. Here is my partial code.

FOR intArrayLoop = LBound(udtFRecord) to UBOUND(udtFRecord)
udtCRecord = udtFRecord(intArrayLoop)
For each udtCRecord.lngNum in ScheduleStructure
SELECT CASE udtCRecord.lngClass
CASE 1
lngNumSeatsAvailable = 2
CASE 2
lngNumSeatsAvailable = 4
CASE 3
lngNumSeatsAvailable = 6
END SELECT
Next


Would this work? Thanks.

Why Does My Control Array Looping Display Differently?
I have these codes that are supposed to load control arrays (days of week), there is only one textbox visible at design time, but I want to use control array to initialize the other six textboxes in order to display (Monday-Sunday) according to local system settings. But when I compile it only shows the error message and when i click OK, it then shows the form with the number "70" on it.
Please could anyone help me figure out what might be wrong and the solution? Thanks in advance


VB Code:
Private Sub Form_Load()Call GetWeekDayCall Update_ControlsEnd Sub  Private Function GetWeekDay()On Error GoTo Error_HandleWeekday(0) = WeekdayName(vbUseSystemDayOfWeek)Weekday(1) = WeekdayName(vbTuesday)Weekday(2) = WeekdayName(vbWednesday)Weekday(3) = WeekdayName(vbThursday)Weekday(4) = WeekdayName(vbFriday)Weekday(5) = WeekdayName(vbSaturday)Weekday(6) = WeekdayName(vbSunday)     Dim i As Integer        For i = 0 To 5    Load txtwkdayname(txtwkdayname.UBound + 1)    txtwkdayname(txtwkdayname.UBound).Top = (txtwkdayname(i).Top +    txtwkdayname(i).Height) + 8    txtwkdayname(txtwkdayname.UBound).Visible = True    Next iError_Handle:MsgBox "Please Check Your Codes"  End Function Private Sub Update_Controls()        Dim i As Integer        For i = 0 To txtwkdayname.UBound        txtwkdayname(i).Text = Weekday(i) & i    Next i    End Sub



When I change the Error message from "Error handler to "On Error Reume Next" I got a diferent result:
Six extra txtboxes were added as I wanted, but then there were numbers from 7(the default textbox), 1,2...6. I wanted them to display, from Monday-Sunday in the local system form.
What should I do to correct this?

Control Array Combo Box Looping Problem!
Hi,

I have a very complicated problem and need help.

I have a control array of 15 combo boxes in a column. Every combo box is loaded with the same ID numbers from the DB. Each time I select an ID from a combo box, I need to loop through the control array and remove the newly selected ID number from the rest of the combo boxes to disable duplicates. E.G. If i select ID# '32' from combo1(17), it must loop through to the last element removing ID '32' and then start from the beginning and remove ID '32' up until element 17 but excluding element 17. The array starts at element 16 and ends at 30. Any help will be appreciated

Thanks

Looping Untill All Records Are Displayed Using An Array.
I want to read every record in a table field (MS Access) and display them in labels. I’m thinking about setting up an array for example:
‘For each row make label(x) and display label’
So far I have this:

The error I’m getting is: compile error Wrong number of arguments or invalid property assignment. Does any one know what is up with my code?

Code:Option Explicit
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

Private Sub Form_Load()

Set cn = New ADODB.Connection

' Create a new connection to the database

cn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=E:vbprice_ranges.mdb;persist security info=false"
cn.Open

Set rs = New ADODB.Recordset
rs.ActiveConnection = cn


'Loop through each record from 1 to the record count and read into that specific array number
' declare an array

Dim x As Integer


' after it gets done with the last record the loop will end
Do Until rs.EOF
      ' fill a label array
      lbleValue(x).Caption = rs![whatever]

      rs.MoveNext
      ' add 1 to x
      x = x + 1
            
    rs.MoveNext
Loop

rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing

End Sub


Plus I need to also display this data in text boxes, the data will then be able to become updated and sent to the database. This all need to happen on the same form. Does any one know any good MS Access and VB6 tutorials or any advice that they can give me on this.
Thanks




Edited by - pfwd.tech on 5/22/2005 4:47:17 PM

How To Retrieve One Element From Within A Looping Array (While Reading From TxtFile)?
Hi,

I am reading from a pipe delimited text file and writing the contents to a table in MSWord. Sample text file:

#9number|#9name|#9activity|#9hours|#9mins
570363|Andrew|RESEARCH/READING|0|12
570363|Brendan|LETTER|0|12
570363|Jonathan||15|48
570363|Jonathan|DRAFTING|4|54
570363|Jonathan|LETTER|2|30
570363|Jonathan|PARTY|0|18
#EOB#

I wish for the table to have a row per person, but their name should appear only once. NB: The text file is already sorted & in order!

Desired Output - please view in Browser:
<BODY>
<TABLE BORDER CELLSPACING=1 CELLPADDING=7 WIDTH=616>
<TR><TD WIDTH="25%" VALIGN="TOP">
<B><P>Name</B></TD>
<TD WIDTH="33%" VALIGN="TOP">
<B><P>Activity</B></TD>
<TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="25%" VALIGN="TOP">
<B><P>Hrs/Mins</B></TD>
</TR>
<TR><TD WIDTH="25%" VALIGN="TOP">
<B><P>Andrew</P>
<P>Brendan</P>
<P>Jonathan</P>
</B></TD>
<TD WIDTH="33%" VALIGN="TOP">
<B><P>RESEARCH/READING</P>
<P>LETTER</P>
<P>UNSPECIFIED</P>
<P>DRAFTING</P>
<P>LETTER</P>
<P>PARTY </B></TD>
<TD WIDTH="17%" VALIGN="TOP">&nbsp;</TD>
<TD WIDTH="25%" VALIGN="TOP">&nbsp;</TD>
</TR>
</TABLE>


Problem:
My code works fine for the 1st 3 lines (i.e. ignores the 1st line and outputs the required values from line 2 & 3 - for 'Andrew' & 'Brendan'), but for I wish for the code to output the name 'Jonathan' just once (on the next row in the table) and then the relevant 'Activities' listed, in the neighbouring cell. at the moment it outputs 'Jonathan' as many times as it actually appears in the text file.

Basically I can't separate out the values (one by one) contained in "onlbgl9(2)" so it outputs them all at once (into one cell), leading to multiple instances of the same name (where it occurs in the text file) - e.g. 'Jonathan'.


Code:


Dim npath As String
Dim inpstring As String
Dim spipe_loc As Integer
Dim epipe_loc As Integer
Dim onlbgl9(1 To 5) As String
Dim i As Integer
Dim j As Integer
Dim iRows As Integer
Dim iColumns As Integer
Dim myTable
Dim filenumber As Integer

iRows = 25
iColumns = 4

Set myTable = ActiveDocument.tables.Add(Selection.Range, _
iRows, iColumns)

j = 1
myTable.Cell(j, j + 0).Range.InsertAfter "Name"
myTable.Cell(j, j + 1).Range.InsertAfter "Activity"
myTable.Cell(j, j + 3).Range.InsertAfter "Hrs/Mins"

filenumber = 9
inpstring = npath & "onlbgl" & Format(filenumber, "0") & ".sec"
Open npath & "onlbgl" & Format(filenumber, "0") & ".sec" For Input As #1
Line Input #1, inpstring
While Not EOF(1)
spipe_loc = 1
Line Input #1, inpstring
If inpstring <> "#EOB#" Then
For i = 1 To 5
epipe_loc = InStr(spipe_loc, inpstring, "|")
If epipe_loc = 0 Then epipe_loc = Len(inpstring) + 1
onlbgl9(i) = Mid(inpstring, spipe_loc, epipe_loc - spipe_loc)
spipe_loc = epipe_loc + 1
Next i
j = 2
' NEXT LINE IS THE BIT I'M TRYING TO ALTER/CHANGE/CAPTURE BUT THE VALUE "onlbgl9(2)" OUTPUTS ALL ITS VALUES (i.e. all the names, including duplicates) - DOES IT NEED TO BE CAPTURED EARLIER IN THE CODE PERHAPS??
myTable.Cell(j, j - 1).Range.InsertAfter (onlbgl9(2) _
& vbCrLf)
If onlbgl9(3) = "" Then
myTable.Cell(j, j).Range.InsertAfter ("UNSPECIFIED" _
& vbCrLf)
Else
myTable.Cell(j, j).Range.InsertAfter (onlbgl9(3) _
& vbCrLf)
End If
End If
Wend
Close #1



I look forward to your comments.

If anyone can suggest an alternative method (surely there must be a simpler way to do this?!!) to the one above I would be interested to hear it/learn from it.

Thank you.

Andy

Looping Through Each Element In An Array With A Variable Number Of Dimensions
Hi Fellas,

I am trying to write functions that are general enough to handle arrays of any size and dimension. Lets say I know the dimension size, and I've read somewhere that I should use a recursive for-loop function to loop through each dimension, but how will I access the elements of the array? The only way I know of is:

element = array( i , j , k , ... , N )

The argument of the array parameters doesn't accept anything but numbers so I can't generate a line of text that adds a comma and another number after each dimension iteration and then just plug in the string. It gives me wrong data type error. Maybe this is the wrong way to go about it. Thanks in advance.

Jay



Edited by - jtung1027 on 9/5/2007 10:35:26 AM

Array Is Only Looping Through Last Value In Array.. Sometimes First
this code will retrieve sub items from a list view and put then into an array, then loop back through the array and put them into a string and i displayed the result in a label at the end for testing purposes.


Code:
Dim strarray() As String
Dim i As Integer
Dim j As Integer
Dim j2 As Integer
Dim listviewsize As Integer
Dim strstring As String

listviewsize = ListViewPrint.ListItems.Count
ReDim Preserve strarray(listviewsize)

For j = 0 To listviewsize
For j2 = 1 To listviewsize
strarray(j) = ListViewPrint.ListItems(j2).ListSubItems(1)
Next j2
Next j

For i = 0 To listviewsize
strstring = strstring & strarray(i) & ","
Next i
label6.Caption = strstring

the problem is that it displays a line of either the first or last value in the array depending on what i set i or j at(the counters), it will also display one extra value that what is actually in the array

the output:

say i had values("1010","1020","1030","1033") in an array the output would be as follows:


Code:
1033,1033,1033,1033,1033,
anyone know what the deal is? i tried initializing my string and even tried to give it a value somewhere in the middle of the array like this, but it will display the same thing always:


Code:
Dim strarray() As String
Dim i As Integer
Dim j As Integer
Dim j2 As Integer
Dim listviewsize As Integer
Dim strstring As String

listviewsize = ListViewPrint.ListItems.Count
ReDim Preserve strarray(listviewsize)

For j = 0 To listviewsize
For j2 = 1 To listviewsize
strarray(j) = ListViewPrint.ListItems(j2).ListSubItems(1)
Next j2
Next j

strstring = strarray(2)' here i gave it the value of the third string but still displays the last...
For i = 0 To listviewsize
strstring = strstring & strarray(i) & ","
Next i
label6.Caption = strstring

update, i got rid of the extra value by adding a minus one at the end of each UBound check for the two array loops:


Code:
For j = 0 To listviewsize - 1 'here
For j2 = 1 To listviewsize
strarray(j) = ListViewPrint.ListItems(j2).SubItems(1)
Next j2
Next j

For i = 0 To listviewsize - 1 'and here
strstring = strstring & strarray(i) & ","
Next i

[Solved][VB6] Array Issues
Hi!
I am currently doing a High School Project
where I have to make 2 dices and show there last ten results in a text box and also be able to save the last ten results in a txt file....i know i have to use a Global array to do this, but I donít know how to use it and where to put it....i have made the dice simulation but i just have to show the results in the text box and to be able to save the last ten results in a txt file. Pls help!
THX in advance!!
Ps. Pls keep in mind Iím still a Beginner in VB

For Next Statement - Until End Or Array?? {Solved}
Hi, im guessing this answer is very simple so sorry for the easy question, I just for some reason couldn't find the answer.

All I want to do is go through an array until you hit the last index, if that makes any sense. I have an array which could have any amount of indexes..

So I want to do something like this:

VB Code:
Private Sub CheckStatus()Dim Checks() As IntegerDim CellText As String     CellText = DetailsGrid.CellText((llRow - 2), 5)    Checks() = Split(CellText, "; ")        For Checks() = 1 To Last        ' Do whatever..    Next    End Sub

So what could I do to find out the last index of an array? Im sure you could use LBound and UBound to do it but I have never used them before. Thanx all for the help!

[SOLVED] Array Problem
Here's the situation. I have a multidimensional array containing the name of a tree, and the number that is associated with that tree. I'm trying to go through every tree's number and divide that number by a number the user enter's into a text box. However, I get this error when I click the Calculate Button.


Code:
Compile Error: Sub or Function not defined


The program then highlights this line:


Code:
Public Sub cmdCalculate_Click()


I seem to be stumped on this one. I've just started Array's, so perhaps I'm missusing the multidimensional array? Anyhow, here's the code.


VB Code:
Private Sub cmdCalculate_Click() 'Get Experience From Text BoxcExp = Val(txtExp.Text) 'For Every Tree, Divide cExp by Tre ExpFor x% = 0 To 5tExp = Val(Trees(x%, 1))nExp = cExp tExpMsgBox "You will need to cut " & nExp & Trees(x%, 0) & "'s to gain " & cExp & "experience points."Next x% End Sub Private Sub Form_Load() 'Create Trees Array'This Array Stores All Trees & Their Experience (Per Cut) Dim Trees(5, 2)Trees(0, 0) = "Regular Tree"Trees(0, 1) = 25Trees(1, 0) = "Oak Tree"Trees(1, 1) = 37.5Trees(2, 0) = "Willow Tree"Trees(2, 1) = 62.5Trees(3, 0) = "Maple Tree"Trees(3, 1) = 100Trees(4, 0) = "Yew Tree"Trees(4, 1) = 175Trees(5, 0) = "Magic Tree"Trees(5, 1) = 200 'Create Variables'These Are Used To Store Experiences' Dim cExp As DoubleDim nExp As Double End Sub


Edit: I just noticed, the VB Syntax Coloring appears to color a portion of my MsgBox differently then Visual Basic is. Does this mean anything of importance?

Thanks ahead of time,
--Brendan

Clear Array....[Solved]
If you want to clear ann array out....is the fastest way to use ReDim?

Find Min And Max From 2D Array [solved]
Hello

How to write a code to find min and max values from 2 dimensional arrays.

Let say the input data is like this:

3 4 5 6 7 6
4 5 6 7 8 9
4 5 3 2 1 4
5 6 7 6 9 2
10 11 12 9 8

Thanks

Option Array - **Solved**
I have a form with six (6) option buttons assembled in an array. Additionally, it has three (3) text boxes and one (1) command button. I am using the following code to ascertian which option button was selected and then it clears two (2) of the three text boxes and sets the focus to the appropriate text box.

The following sub fires when the form opens. How can I prevent it from firing and why would I be getting the following error message:


VB Code:
Private Sub optButton_Click(Index As Integer)    Select Case Index        Case 0 To 1            Me.cboTitle.Text = ""            Me.txtLastName.Text = ""            Me.txtTaxNumber.SetFocus        Case 2 To 3            Me.txtTaxNumber.Text = ""            Me.cboTitle.Text = ""            Me.txtLastName.SetFocus        Case 4 To 5            Me.txtTaxNumber.Text = ""            Me.txtLastName.Text = ""            Me.cboTitle.SetFocus    End SelectEnd Sub


I am getting a runtime error '5' Invalid procedure call or argument on the following line

VB Code:
Me.txtTaxNumber.SetFocus


If I rem this line out the remaining code works fine.

Any suggestions!!

Copy An Array *SOLVED*
is there is easier way to copy array values?

dim Arry() as string

redim arry(3)

arry(1)="Jim"
arry(2)="Bob"
arry(3)="Harry"

Dim NewArry() as string

redim newarry(ubound(arry))

for a= 0 to ubound(newarry)
newarry(a)=arry(a)
next a

VBA Array Trouble - SOLVED
Hi all,

I'm in MSAccess 97, and this code is behind a form.

Essentially, I've got 42 object 'boxes' that are visible or hidden based on the date. (A mock calendar really) Ie, it decides how many days in the month, and shows that many days, in the right places as a calendar would show. This works, and it displays the day number on each box.

Here's the tricky part. I've got an array of days, and I'd like it to change the forecolor of the box if the day in in the array. Seems simple, but it doesn't seem to work. It changes the colour only on the last date it finds in the array, even though I can see in the debug that it's doing the checking and matching in all the right places. (I think)

Can anyone see what I'm obviously missing? I'm pretty new to working with arrays, so it's probably just some dumb thing I don't know.

Private Sub FixDaysInMonth(intStartDay As Integer)

' Turn on and off buttons in the currently displayed month.
Dim intRow As Integer
Dim intCol As Integer
Dim intNumDays As Integer
Dim intCount As Integer
Dim strTemp As String
Dim DB As Database, RS As Recordset, Count As Integer
Dim AnArray()
Dim i As Long

intNumDays = DaysInMonth(Me!Month)
' If the chosen date is past the last day in this month,
' then just select the last day of this month.
If Me!Day > intNumDays Then
Me!Day = intNumDays
End If

intCount = 0
Count = 0

For intRow = 1 To 6
For intCol = 1 To 7
If (intRow = 1) And (intCol < intStartDay) Then
Me("lbl1" & intCol).Visible = False
Else
intCount = intCount + 1
Debug.Print intCount

'fill in the array of dates to check against

Set DB = CurrentDb()
Set RS = DB.OpenRecordset("qryCheck")
Count = 0
ReDim Preserve AnArray(0)
' Fill the array.
RS.MoveFirst
Do Until RS.EOF
' Fill the array row with the day only part of the date.
AnArray(Count) = RS![DatePart]
' Increase the number of elements in the array
' by one to accommodate the next record.
ReDim Preserve AnArray(UBound(AnArray) + 1)
Count = Count + 1
RS.MoveNext
Loop
' Remove the remaining empty array row.
ReDim Preserve AnArray(UBound(AnArray) - 1)
RS.Close
' View the array contents.
For i = 0 To Count - 1

strTemp = "lbl" & intRow & intCol

With Me(strTemp)
If intCount <= intNumDays Then
If Not .Visible Then
.Visible = True
End If
.Caption = intCount

If AnArray(i) = intCount Then
Debug.Print "AnArray(i)=" & AnArray(i) & ",intCount=" & intCount & ",strTemp=" & strTemp
Me(strTemp).ForeColor = 255
Else
.ForeColor = 16711680
End If

Else
If .Visible Then
.Visible = False
End If

End If
End With
Next i
End If
Next intCol
Next intRow
End Sub

Thanks for any help you can be!

[SOLVED] Array Of Dates
Hey guys,
I have an array of Dates..... how can I get to know which Date is the least recent?
I searched for "date" in the forums, but I only found alot of posts about comparing 2 dates.......
......don't tell me I would have to compare each date with Now() !!!!!

Thanks



Edited by - Nasty on 2/14/2006 12:28:02 AM

Array Problem [SOLVED]
I have a problem. I don't fully understand the function of an array in VB (6.0) so I write my problem here. I need to create an array with 400 rows and 5 columns. In each of them I put information and later I read it. Howeer, when I read the information, all I get is "empty", as if there would be no information. I add my code below, so if you can tell what I do wrond, I I would appreciate it very much. Thank you.

I have simplified the code, so don't worry about how it looks like I would add same things on every row in the array, heh.

Code:
Dim taulukko() As Variant
Dim luku as Integer
Dim iluku as Integer

luku = 400
iluku = 0
ReDim taulukko(luku, 5)

Do Until iluku = 400
  taulukko(iluku, 0) = sKone
  taulukko(iluku, 1) = sKaytto
  taulukko(iluku, 2) = sVvvvkk
  taulukko(iluku, 3) = satosa
  taulukko(iluku, 4) = sTunnit
  iluku = iluku + 1
Loop

' Here I do something else Until it is time to read the data from array

luku = 0
Do until luku = 400
  sKone = taulukko(luku, 0)
  sKaytto = taulukko(luku, 1)
  sVvvvkk = taulukko(luku, 2)
  sSatosa = taulukko(luku, 3)
  sTunnit = taulukko(luku, 4)
  luku = luku + 1
Loop



So, In the second loop, where I read the data, it seems like there would be nothing. All I get from array is Null. Is my array defined wrong way? Do I need to define it like:

ReDim taulukko(luku, 1, 2, 3, 4) ????

Any help is appreciated. Thank you.

- - - - - - - - - - - - - - - - - - - -
 Long days and pleasant nights
   - Roland the Gunslinger
 - - - - - - - - - - - - - - - - - - - -

Edited by - Karibu on 9/20/2005 12:17:47 AM

PE Section To Byte Array[solved]
I want to add security to my application, so I check different sections
with help of PE headers. but I am stuck.

if I could get code section(".text" part) to a byte array I can crc check that.

But I don't know how to do it hard to get sections to bytearray..
so I either can dump it to disk check crc delete, or do a crc check of
it in memory with those bytes..

but when I try do that my app crashes.
anyone know how to accomplish that..?
My function/code looks like this..


Code:
Dim IDH As IMAGE_DOS_HEADER
Dim INH As IMAGE_NT_HEADERS
Dim startLen As Long, stopLen As Long, pSize As Long, offset As Long
Dim Img As IMAGE_SECTION_HEADER
Dim ImgFile() as byte
Dim i as long
CopyMemory IDH, bytearr(0), Len(IDH)
If IDH.e_magic <> IMAGE_DOS_SIGNATURE Then
Exit Function
End If
CopyMemory INH, bytearr(IDH.e_lfanew), Len(INH)
If INH.Signature <> IMAGE_NT_SIGNATURE Then
Exit Function
End If
pSize = &H400000 + INH.OptionalHeader.BaseOfCode
startLen = (inh.OptionalHeader.ImageBase + inh.OptionalHeader.BaseOfCode) - pSize
stopLen = startLen + INH.OptionalHeader.SizeOfCode

ReDim ImgFile(INH.OptionalHeader.SizeOfCode)
CopyMemory ByVal ImgFile(0), bytearr(inh.OptionalHeader.BaseOfCode), inh.OptionalHeader.SizeOfCode
'inh.FileHeader.NumberOfSections
i = 0
offset = IDH.e_lfanew + Len(INH)
For i = 0 To ImgNtHeaders.FileHeader.NumberOfSections - 1
CopyMemory Img, bytearr(offset + i * Len(Img)), Len(Img)
'I am stuck :S I want dump section or make crc check...
CopyMemory ImgFile(0), bytearr(INH.OptionalHeader.BaseOfCode), Len(ImageBase)
next i


/atlantis

Control Array Problem - Solved
VB Code:
Private Sub Form_Unload(Cancel As Integer) Dim varProduct1 As String, Selected As Integer, I As Integer     For I = 0 To Product().Count - 1        If Product(I).Value = Checked Then            Select Case Product(I)             Case 0                varProduct1 = "STAR"                    Case 1                varProduct1 = "SEXP"                    Case 2                varProduct1 = "W2BN"                    Case 3                varProduct1 = "D2DV"                    Case 4                varProduct1 = "D2XP"                    Case 5                varProduct1 = "WAR3"                    Case 6                varProduct1 = "W3XP"                End Select        End If        Next I     WriteStuff "Main", "Username", txtUsername.text    WriteStuff "Main", "Password", txtPassword.text    WriteStuff "Main", "Home", txtHome.text    WriteStuff "Main", "Server", txtServer.text    WriteStuff "Main", "CDKey", txtCDKey.text    WriteStuff "Main", "Cdkey2", txtCDKey2.text    WriteStuff "Main", "Cdkey2", txtCDKey2.text    WriteStuff "Main", "Product", varProduct1    End Sub


I have a array of Checkboxes, Product(x). X = 0,1,2,3,4,5

1) I want to be Able to Detect which Option is Displayed, and Give it a Name ( varProduct1 )

2) when i Click one Checkbox, the rest of the Checked Boxes Become Unchecked

THe Above code doesn't seem to be working, and i am not sure how to do #2

How Pass Array In Function? &lt;Solved&gt;
How can I pass Array with its value in Function?


VB Code:
Private Sub Command1_Click()Dim A(1 To 40) As Double    For i = 1 To 40        A(ad) = i    Next    ChArray (A()) 'Pass Array To FunctionEnd Sub Public Function ChArray(ByRef b() As Double)For h = 1 To 40    Debug.Print b(h) 'Get The ValueNext hMsgBox "Done" End Function

Array And Module Question *SOLVED*
I use the same code in a number of forms so to stop repeating the code I created a module and put the code in there. However when I call the function I get an error "Sub or Function not defined" and the word "Text1" is highlighted. Can arrays be used in functions or would I need to repeat the code in each form?


Code:
Public Function Validate()
Dim i As Integer

For i = 0 To 35
If Text1(i) = "" Then
MsgBox "Please fill in all details", vbInformation
End If
End Function

Split String To Array [SOLVED]
How can i turn this string into a array??
"{something with space} oneword next item {and so on}"

Everything inside {} shall be in the same value.

It shall be like:
Array(0) shall be "something with space"
Array(1) shall be "oneword"
Array(2) shall be "next"
Array(3) shall be "item"
Array(4) shall be "and so on"

I hope you understand how i want it.


/Rickard

Control Array Ubound? [sOLvEd]
Dim i As Byte
For i = 1 To UBound(Form1.picPowerPC)
With picPowerPC(i)
.CurrentX = (.ScaleWidth / 2) - (.TextWidth(Caption) / 2)
.CurrentY = 0
End With
Next i

This says 'expected array', is their anyway to find the highest number of a control array? this is part of a function in a module.

Redim Preserve Array (SOLVED)
VB Code:
Private Type Stock    m_Date As String    m_Open As Double    m_High As Double    m_Low As Double    m_Close As DoubleEnd Type     -------------------------------------Dim arrStocks(0) As StockarrStocks(0).m_Close = 5.9    ReDim Preserve arrStocks(UBound(arrStocks) + 1) As StockarrStocks(1).m_Close = 5.9


above gives me a "already dimensioned array"


VB Code:
Dim arrStocks() As Stock  ReDim Preserve arrStocks(UBound(arrStocks) + 1) As Stock


i get "out of range script" error

How Many Array Elements [solved, Thnx]
how can I know how many elements are in some array?

that is because I want to create controls on the fly, i.e. a label with different caption each time I press a button. So, the next time the user press the button I need to know what element I'll create: label1(i).caption i = ?

[ Not Yet Solved ]Control Array For Textbox
hai friends,

       in the attachment farm.zip, when the user clicks the data grid & press edit, the values which is pointing in the data grid must be present in the text boxes. also, the textboxes must display according to the columns of the data grid- i am going to use control arrays.

  i tried for datagrid1.col,datagrid1.columns

help me to proceed

thanks & Regards





Edited by - Geethahiren on 4/20/2005 10:29:18 PM

Playing MP3 From A Byte Array !! ** SOLVED **
Hi,
    Is it possible to play a MP3 file from a byte array instead of a file.

And temp file creation is not a solution.

Actually I want to first read a big file (90 Mbs +)
and then store it in a byte array.

And then Playing selected Portions Instead of the whole File.By Reading
the contents of the array !!

Is it Possible ??


Regards

Er. Gurpreet Singh
C.E.O Sukhmani Software
New Delhi


Difficult Things are Those that can be done Instantly.

Impossible things are those which take little long - Unknown

Edited by - gurpreet2311 on 4/20/2004 10:45:50 AM

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