
-----------------------------------
cool dude
Mon Dec 26, 2005 11:09 am

sending info from one form to the other
-----------------------------------
hi how do u send information from one form to the other form? for instance if i chose one of the options in the combo box how would i know which option i chose in the other form?

-----------------------------------
cool dude
Mon Dec 26, 2005 1:05 pm


-----------------------------------
***Edit*** 
does anybody know wats wrong with this code. i made a combo box with the choices easy, medium, hard, and insane. i want to figure out which one was chosen and then i want to send it to my main program where the chosen speed will occur. 


Option Explicit 

Dim speed(3) As Integer 

Private Sub cboDifficulty_Change() 
    If cboDifficulty.Listindex = 0 Then 
       cboDifficulty.Listindex = speed(0) 
    ElseIf cboDifficulty.Listindex = (1) Then 
        cboDifficulty.Listindex = speed(1) 
    ElseIf cboDifficulty.Listindex = (2) Then 
        cboDifficulty.Listindex = speed(2) 
    ElseIf cboDifficulty.Listindex = (3) Then 
        cboDifficulty.Listindex = speed(3) 
    End If 
End Sub 

The error that i get is subscript out of range in the main program

-----------------------------------
HazySmoke)345
Mon Dec 26, 2005 2:51 pm


-----------------------------------
Well, When I ran the program, the program didn't run through the script at all. I don't really know why that happens. But I think I know what's wrong. First, maybe you shouldn't have created an array for speed. Speed can be either 0,1,2 or 3, so I would change it to something like this:Dim speed As Integer

Secondly:ElseIf cboDifficulty.Listindex = (1) Then  Are you really supposed to put brackets around the 1?  :lol: 

Thirdly:cboDifficulty.Listindex = speed(0) Shouldn't it be the other way around, as in, speed = cboDifficulty.Listindex

-----------------------------------
HazySmoke)345
Mon Dec 26, 2005 2:57 pm


-----------------------------------
Oh, and, if you want to send information inter-Form-ly. This is what you do. Let's say that you created Text1, cmd in Form1 and Text2 in Form2. And you want to send whatever is written in Text1 to Text2 by the click of the button. This is what you write

Private Sub cmd_Click()
    Form2.Text2 = Form1.Text1
End Sub

-----------------------------------
cool dude
Mon Dec 26, 2005 3:32 pm


-----------------------------------


Secondly:ElseIf cboDifficulty.Listindex = (1) Then  Are you really supposed to put brackets around the 1?  :lol: 



No u don't have to place the brackets on the 1 i didn't even notice that i did that. :oops:  but that does nothing anyways so thats not the problem.


Thirdly:cboDifficulty.Listindex = speed(0) Shouldn't it be the other way around, as in, speed = cboDifficulty.Listindex



yes it should be around srry for that stupid mistake

Now back to the main problem. watever speed the user chooses in the combo box that speed must effect the main program. which means if they chose easy than my main program should know that and adjust the timer intervals smaller or greater to make it go faster or slower. now i don't know how to pass the variable speed that they choose in the combo box to my main program. the example u gave me

 
Private Sub cmd_Click() 
    Form2.Text2 = Form1.Text1 
End Sub


this is only good if u want the information from one textbox to the other i dunno how to do the same thing with the speed. can u please explain how i would go about doing this?

-----------------------------------
cool dude
Mon Dec 26, 2005 4:34 pm


-----------------------------------
okay i fixed it all up and all i need to know is when the user clicks on the command button "play" how can i send the speed from the settings form to the main game. at the moment, because i'm not sending the speed the user chose, it sets the speeds value to 0. (default).

-----------------------------------
HazySmoke)345
Mon Dec 26, 2005 4:35 pm


-----------------------------------
If you want to use a same variable in two forms. You can create a module and write this in it:
Public speed As IntegerSo that "speed" can be used in the whole project.

-----------------------------------
cool dude
Mon Dec 26, 2005 5:12 pm


-----------------------------------
oh my god i completely forgot to declare speed as a module. thanks a lot!!! finally i got it working. :)  + 5 bits
