|
-
Apr 3rd, 2005, 10:47 PM
#1
Thread Starter
Junior Member
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??
-
Apr 3rd, 2005, 11:00 PM
#2
Re: looping thru an assigned array
You already appear to have that.
VB Code:
dim x(3) as integer
x(0) = 2
x(1) = 200
x(2) = 100
x(3) = 400
EDIT: Misread request.
Last edited by dglienna; Apr 4th, 2005 at 02:46 AM.
-
Apr 4th, 2005, 02:36 AM
#3
Re: looping thru an assigned array
 Originally Posted by kunckle
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??
Can you explain a bit more. I don't quite understand what you're asking. In your example, X(0) = 2, X(1) = 20, X(2) = 100 and x(3) = 400. So what do you want to do?
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
Apr 4th, 2005, 03:30 AM
#4
Thread Starter
Junior Member
Re: looping thru an assigned array
ok i was actually trying to do this :
Private Sub cmdStart_Click(Index As Integer)
Dim i As Integer
Dim X()
Dim Y()
Dim Data
X() = Array(14.1, 28.2, 42.3, 56.4, 70.5, 84.6, 98.7, 112.8, 126.9, 141, 155.1, 169.2)
Y() = Array(14, 28.1, 42.2)
Do
ret = eCIdx0249SetVelocity(handle, 0, 10)
ret = eCIdx0249SetAcceleration(handle, 0, 200)
ret = eCIdx0249setPosition(handle, 0, X(i))
ret = eCIdx0249SetDeceleration(handle, 0, 200)
ret = eCIdx0249Start(handle, 0)
ret = eCIdx0249SetVelocity(handle, 1, 10)
ret = eCIdx0249SetAcceleration(handle, 1, 200)
ret = eCIdx0249setPosition(handle, 1, 14.1)
ret = eCIdx0249SetDeceleration(handle, 1, 200)
ret = eCIdx0249Start(handle, 1)
(handle is my device name)
ret = eCIdx0249ReadStatus(handle, 0, Data)
If Data = 257 Then
i = i + 1
End If
Loop While X <= 8
above is a portion of my code
(those commands with eCIdx0249 are commands for my hard ware)
i also have a timer running behind:
Private Sub Timer1_Timer()
Dim pPos
Dim pBos
ret = eCIdx0249ReadActualPos(handle, 0, pPos)
Label4.Caption = pPos
ret = eCIdx0249ReadActualPos(handle, 1, pBos)
label5.Caption = pBos
End Sub
(the above is to retrieve the actual position of the slider and i set the interval to 100)
initally i though i did something wrong with the array thing
but now i solved the array thing however a new problem arises the timer cannot seems to update the position of the slider anymore..
can someone help me pls? thks...
-
Apr 4th, 2005, 03:39 AM
#5
Re: looping thru an assigned array
You are looping while x<=8, but I don't see where you are changing it. You also have an array with the same name. That isn't good to do.
Wouldn't you want to declare your variables in the Timer as Public? Declare them at the top of the form in General Declarations so that they are accessible in all modules in that form. If you need them in all of the program's forms, then you have to declare them in a module.
-
Apr 4th, 2005, 05:13 PM
#6
Re: looping thru an assigned array
 Originally Posted by kunckle
now i solved the array thing however a new problem arises the timer cannot seems to update the position of the slider anymore.
Try putting a DoEvents statement within the body of your loop. That should allow your Timer event to be processed.
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
Apr 4th, 2005, 08:06 PM
#7
Thread Starter
Junior Member
Re: looping thru an assigned array (solved)
oh thks! the doevents statement did the trick =)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|