PDA

Click to See Complete Forum and Search --> : how can you make this moer erffeicent?


qpabani
Apr 15th, 2002, 12:32 PM
how can you make this moer erffeicent?

Dim xOrder As String

Private Sub Command1_Click()
Dim x As Long
On Error GoTo mFix
'MsgBox xOrder
toMove = Val(Text1.Text) 'Label(1)
'move 3 over
For x = 1 To 4
If Mid$(xOrder, x, 1) = toMove Then
'MsgBox "Position " & x
'MsgBox Label1(Mid$(xOrder, x - 1, 1)).Left 'The left of the label to the left of the one to move

'MsgBox "Order " & xOrder & " Replacing " & Mid$(xOrder, x - 1, 1) & " with " & Mid$(xOrder, x, 1)

test = Label1(Mid$(xOrder, x, 1)).Left 'The left of the one to move
test2 = Label1(Mid$(xOrder, x - 1, 1)).Left

Label1(Mid$(xOrder, x - 1, 1)).Left = test
Label1(Mid$(xOrder, x, 1)).Left = test2

xOrder = Replace$(xOrder, Mid$(xOrder, x - 1, 1) & Mid$(xOrder, x, 1), Mid$(xOrder, x, 1) & Mid$(xOrder, x - 1, 1))
Exit For
End If
Next

Exit Sub
mFix:
MsgBox "Cannot move more left"
End Sub

Private Sub Form_Load()
xOrder = "0123"
End Sub

Jamel rose
Apr 19th, 2002, 02:22 PM
What is it that you are trying to do? Change the order of items in a string? Move the position of a control from one location on a page to another?