1.

Solve : Just started learning VB and need help please?

Answer»

Hi guys I wonder if you can help me I have just started to learn VB6 and am playing around with a small program I have just created a splash screen etc,and now want to create my next page. I have created a new form and have put six buttons on it that relate to six questions about scooby doo. What I would like help with is

how do I make the program move from one form to another using the next command on the form

how do I make the buttons link to the questions i.e SHOW when the right q has been selected etc

And finally I have tried to find code already written that I can cut and paste but when I cut and paste the progs won't run. Can you please tell me where on the code page the code has to be pasted.

I know this may seem basic to some but we all have to start somewhere
many thanks
Quote

how do I make the program move from one form to another using the next command on the form

If you are asking how to get from one form to another, here's how:

Assuming you've created the second form, use code similar to this for button_click (or whatever you call the BUTTON in question).

Code: [Select]Dim SecondForm As Form2
SecondForm.Show
Of course, that can be used with If/Then statements, and the like. You can change the SecondForm to whatever you want, like most variables, but the Form2 bit must be the name of the form you are trying to access.

If you want to close the first form as the second opens, you might use something like this:

Code: [Select]Dim FirstForm As Form1
Dim SecondForm As Form2

SecondForm.Show
FirstForm.hide
Do not use FirstForm.Close. I've found that ANY form used with .Close will exit the program.

Quote
how do I make the buttons link to the questions i.e show when the right q has been selected etc

If I read this correctly, you could have the correct answer go to a Form that says, "You're right" or something like that. The others can link to a form that tells you you messed up.

Quote
And finally I have tried to find code already written that I can cut and paste but when I cut and paste the progs won't run. Can you please tell me where on the code page the code has to be pasted.

That depends. If you want it to be code for when, say, ButtonC is clicked, you'd put it under the Sub called ButtonC_Click. If it is to be run when the form loads, it would go under Form1_load, if I recall correctly. (I can't open Visual Studio right now (stupid IE 7) so I can't look it up.)

Hope it helps!My Form works without typing Dim Form2 As Form2
Because is already save in a slot the form has

Anyway i was trying to ague i am just saying this work for me

scania11 check this toturial http://www.vbwm.com/learnvb/tutorials.aspGuys Thank you very much I will take onboard your advice.

again thaks Quote
My Form works without typing Dim Form2 As Form2
Because is already save in a slot the form has

Okay, the Form does work without the "Dim"s. I was under the impression she wanted to open that second form with the first form. Am I correct, scania11?

ALSO, I don't understand "Because is already save in a slot the form has". Can you please clarify?
To dilbert this is how i will do it.
Coding a simple question with no DIM statement
Coding with simple code
T-Chai way
The easier way (mayby)
This how i will do the code for 2 simple question
Let say we are going to code 2 simple question about this forum
There will be 3 form:
form1 - Question 1 Who is pavane
form2 - Question 2 How crazy is pavane
form3 - Answer

form1 Next button = Private Sub Next1_Click()
form2 Next button = Private Sub Next2_Click()
form2 Back button = Private Sub back_Click()
form3 Show the answer button = Private Sub back_Click()
form3 Quit button = Private Sub End_Click()

As you see i havent name the option because i cant be *censored*
You can do as many question as you want
My spelling is crap

Tha's great T-Chai. What is the program called? Mac/Pavane is a Loon?Very well done, if it works, do it. My way was one way and I use Visual Basic .NET, maybe there's a difference. If not, then well... is my method not do-able as well? I made a Millionaire game and used similar code. (Only, I used images that linked. It looked a lot like the actual game. But that got lost due to a virus on my previous machine...)

Code: [Select]Private Sub Button1_Click(ByVal SENDER As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim question1 As Form1
Dim question2 As Form2
Dim answer As Form3
Dim wronganswer As Form4

If RadioA.Checked = True Then
answer.Show()
question1.Hide()
Else If RadioB.Checked = True Then
wronganswer.Show()
question1.Hide()
Else If RadioC.Checked = True Then
wronganswer.Show()
question1.Hide()
End If
End Sub
That would be for the first form, when "next" is clicked. I'm leaving out the other forms because that can be anything you want. But this would work, no?

EDIT: Oh wait, that's almost identical. Oh well...Guys many thanks for going to all that trouble I will try it later

T-CHAI your spelling is fine with me my friend again many thanks for your time.

Scania GX man - Visual Basic 6.0

Dilbert - i naver use VB net so i dont know wheather is a different codeing stye or not but the language should be the same for all VB and Flash coding it has nearly the same laguage as VB as well
But hey you code it way shorter than mine Well, I didn't include the other forms. Actually, my Form1 length is about the same as your Form1 by itself. My Form2 would be about the same, and 3 and 4 would be short (having Continue and Start Over, respectively.) I guess my version would be a little simpler, as it uses simple code, but I don't think you need dynamite to clean up paper. I still say your code works, we just have different methods. Sorry if I'm replying to an old topic.

Why do you need six different Forms to make a simple quiz. They can all be done on one Form. You just need your questions and answers in an array and just keep moving through them.

Here is a quiz I made many years ago and it uses Microsoft Agents to bring a bit of life to it. Yeah... I never did get proficient with VB.


Discussion

No Comment Found