• Log in or sign up for an account here: https://www.sythe.org/login

Command button help

Joined
Mar 16, 2007
Sythe Gold
0
Messages
1,162
Location
Michigan
I'm making a rs client and I have command buttons for the worlds.
I am setting all the world links for my buttons but i want to know if
there is a faster way. Is it possible to do something like...

Command1-80_Click() ??? (1-80) is command buttons 1-80

I want to do this instead of

Command1_Click()
Command2_Click()
Command3_Click() Ect...

Heres what I have so far...only 3 done i need 145 thats why I want to know if this it is possible.

Private Sub Command81_Click()
WebBrowser1.Navigate "http://" & GetPrefix(Command81.Caption) & ".runescape.com/l1,p0,j1"
End Sub

Private Sub Command82_Click()
WebBrowser1.Navigate "http://" & GetPrefix(Command82.Caption) & ".runescape.com/l1,p0,j1"
End Sub

Private Sub Command83_Click()
WebBrowser1.Navigate "http://" & GetPrefix(Command83.Caption) & ".runescape.com/l1,p0,j1"
End Sub
 
The first thing you need to do is make 1 button which will be the main button.

You MUST change its index value to 0

Now I called my button "buttons" and this is how to make it generate any number of controls you want.

Code:
Private Sub buttons_Click(Index As Integer)
WebBrowser1.Navigate "http://" & GetPrefix(Index + 1) & ".runescape.com/l1,p0,j1"
End Sub

Private Sub Form_Load()
Dim num As Integer
Dim y As Integer
Dim x As Integer
Dim maxx As Integer
y = 5
x = 0
maxx = 2
For num = 1 To 79
    Load buttons(num)
    If x = maxx Then
        x = 0
        y = y + 5
    Else
        x = x + 1
    End If
    buttons(num).Move x * 120, y * 3, 100, 5
    buttons(num).Visible = True
    buttons(num).Caption = "World " & num + 1
Next num
End Sub
 
Ok, if you have the buttons already made. you will have to do this:
click on a button and scroll down to the "Index" property and but a number there, do this for every button that will be used for a world number.

Once you've done that change the name of the button to something like "cmdWorld", do that for every button. Every world button HAS to have the same name.

Then you have to much a function something like this.
Code:
private sub SwitchWorld(intWorld as integer)
    webbrowser1.navigate
end sub

then you would add this to your world button's click event.
Code:
private sub cmdWorld_Click(Index as integer)
    switchworld cint(val(cmdworld(index).caption))
end sub[code]

That will only work if you're caption says the world number if it says something like "World 2" it won't work.

EDIT:
lol
i was in the middle of typing this when i got a call from a company that just hired me, so i had to leave to fill out paperwork, came back 4 hours later and stuart beat me to it :(
*shakes fist*
 
Alright stuart, I get the first little part but what's this do?

Private Sub Form_Load()
Dim num As Integer
Dim y As Integer
Dim x As Integer
Dim maxx As Integer
y = 5
x = 0
maxx = 2
For num = 1 To 79
Load buttons(num)
If x = maxx Then
x = 0
y = y + 5
Else
x = x + 1
End If
buttons(num).Move x * 120, y * 3, 100, 5
buttons(num).Visible = True
buttons(num).Caption = "World " & num + 1
Next num
End Sub

Is all that needed or can I just use

Private Sub buttons_Click(Index As Integer)
WebBrowser1.Navigate "http://" & GetPrefix(Index + 1) & ".runescape.com/l1,p0,j1"
End Sub
 
What that part does is sort the buttons into rows and columns. You have to set your forms scalemode to pixel those.

It will look like this:

World 1 | World 2 | World 3
World 4 | World 5 | World 6
World 7 | World 8 | World 9

ECT
 
Ok well your using the 2 big buttons to change between free and members so this would have nothing to do with it...

You should use 2 frames those, throw your free and members buttons into different frames and just flick between the frames with the 2 buttons.
 
Runescape Gamblingrunescape gambling
Back
Top