Jump to content

VB Problem


YeTi

Recommended Posts

Right well firstly i am trying to make an installer in VB i know it might not be the best program to make it in but its the best i can do. I am making it out of seperate forms i am unsure as to what other feature to use so if somebody knows a better way can you poing it out to me.

 

The installer i am making is for a TC i am working on.

 

Right it starts off with this window.

 

user posted image

 

Don't worry about the big space someone else on the team is designing a image to go there.

 

The proceed button on that form uses the command

 

 

Private Sub cmdproceed_Click()frmstart.ShowUnload MeEnd Sub

 

 

cmdproceed obviously being the proceed command button and frmstart is the next form that the program is supposed to load and it does it switches over to this form.

 

user posted image

 

Now this form is mainly copyright information although it hasn't all been added yet. Anyway the exit and back buttons are self explanitory.

 

Now to make sure that the user agrees to the terms i have added a check box i want the program to not load the next form if the check box isn't selected. But us the msgbox command to tell the user that the check box isn't checked. The code i am using for this button is

 

 

Private Sub cmdcontinue_Click()If chkagree.Value = False Then   MsgBox "You Didn't Click The Tick Box", vbQuestion, "Do You Agree"ElseIf chkagree.Value = True Then   frmchoose.ShowEnd IfEnd IfEnd Sub

 

 

cmdcontinue is the name of the next command button

chkagree is the name of the check box

frmchoose is the name of the next form

 

Right i am wanting to add a unload me command to the coding of that button somewere but i can't get the coding to function properly. When i click the command button with the check box not checked it does display the correct message box i then click ok on the message box and it goes back to the form. I then try checking the message box and clicking next but nothing happens.

 

Can somebody please tell me what i am doing wrong and also tell me were i would need to put the unload me command. Also if there is a better way of doing it then please tell me that also.

 

Thanks YeTi

user posted image
user posted image
R.I.P. Chi Shingi Meiyo

 

21/09/2005 - 07/03/2007

Andolini Mafia Family

 

16/08/2008 - Current

Link to comment
Share on other sites

Private Sub cmdcontinue_Click()  If chkagree.Value = True Then     frmchoose.Show  Else     MsgBox "You Didn't Click The Tick Box", vbQuestion, "Do You Agree"  End IfEnd Sub

 

Link to comment
Share on other sites

Private Sub cmdcontinue_Click()  If chkagree.Value = True Then     frmchoose.Show  Else     MsgBox "You Didn't Click The Tick Box", vbQuestion, "Do You Agree"  End IfEnd Sub

 

That just makes it pop up the message box wether or not the check box is clicked.

user posted image
user posted image
R.I.P. Chi Shingi Meiyo

 

21/09/2005 - 07/03/2007

Andolini Mafia Family

 

16/08/2008 - Current

Link to comment
Share on other sites

Private Sub cmdcontinue_Click()  If chkagree.Value = True Then     frmchoose.Show  Else     MsgBox "You Didn't Click The Tick Box", vbQuestion, "Do You Agree"  End IfEnd Sub

 

That just makes it pop up the message box wether or not the check box is clicked.

Did a bit of testing. It seems .Value can't be compared with "True", only "1" or "0"

 

 

Private Sub cmdcontinue_Click()  If chkagree.Value = 1 Then     frmchoose.Show  Else     MsgBox "You Didn't Click The Tick Box", vbQuestion, "Do You Agree"  End IfEnd Sub

 

Link to comment
Share on other sites

Yeah that worked thanks alot. Edited by YeTi

user posted image
user posted image
R.I.P. Chi Shingi Meiyo

 

21/09/2005 - 07/03/2007

Andolini Mafia Family

 

16/08/2008 - Current

Link to comment
Share on other sites

As I said in another thread, why does it need to be locked? Someone might have a way to improve your code, yaknow?

Good point i've edited it out.

user posted image
user posted image
R.I.P. Chi Shingi Meiyo

 

21/09/2005 - 07/03/2007

Andolini Mafia Family

 

16/08/2008 - Current

Link to comment
Share on other sites

A better technique is to use a single form with frames that are placed on top of each other. The row of buttons along the bottom are not covered up by any frames, though. At design time, you set Visible to False on all but the first frame. Then, in the command button code, you hide that frame and show the next/previous according to the button. By putting the Next and Back buttons in a control array and creating the frames as a control array, the code would be extremely extendable and easy to work with.

 

Control arrays are a very powerful part of object-oriented programming. Use them whenever you can. smile.gif

Link to comment
Share on other sites

A suggestion would be instead of having to worry about the Msgbox if the checkbox isn't ticked, have the command button disabled. Then when the checkbox is clicked (If the value is then set to 1 (True, checked)), you can enable the command button.

 

Then do the same for if the checkbox is clicked and the value becomes 0, make the button disabled. It will mean that you can click the button unless the checkbox is ticked.

Link to comment
Share on other sites

Use them whenever you can. smile.gif

Thanks i will. And chalk i hadn't thought of that i will try and make that i've not come across the code yet so if you could point it out i'd appreciate it.

user posted image
user posted image
R.I.P. Chi Shingi Meiyo

 

21/09/2005 - 07/03/2007

Andolini Mafia Family

 

16/08/2008 - Current

Link to comment
Share on other sites

 

Private Sub chkAgree_Click()'Determine if checkbox is ticked:If chkagree.Value = True Then 'is ticked: cmdNext.Enabled = True 'enable "Next" buttonElse 'is not ticked: cmdNext.Enabled = false 'disable "Next" buttonEnd IfEnd Sub

This is the "Click" event for the checkbox. When the box is ticked, it enables the button. When the box is unticked, it disables the button.

 

At design time:-

  • Set the Value property of the checkbox to 0 - Unchecked
  • Set the Enabled property of the "Next" command button to False
This will mean that when the user views the form, the "Next" button will not be clickable until they tick the checkbox. If they then untick the checkbox, the command button is disabled and cannot be clicked. Basically, it links the button enablement directly to the checkbox value, which is the conventional way of presenting a license agreement in a program.

 

Always put lots of comments in your code and make sure they are perrfectly consistant. That way the program code will still make sense to you years after you made it. Also, with lots of consistant commenting, other people who work on the project will be able to understand it more easily.

Link to comment
Share on other sites

Private Sub chkAgree_Click()'Determine if checkbox is ticked:If chkagree.Value = True Then 'is ticked: cmdNext.Enabled = True 'enable "Next" buttonElse 'is not ticked: cmdNext.Enabled = false 'disable "Next" buttonEnd IfEnd Sub

This is the "Click" event for the checkbox. When the box is ticked, it enables the button. When the box is unticked, it disables the button.

 

At design time:-

  • Set the Value property of the checkbox to 0 - Unchecked
  • Set the Enabled property of the "Next" command button to False
This will mean that when the user views the form, the "Next" button will not be clickable until they tick the checkbox. If they then untick the checkbox, the command button is disabled and cannot be clicked. Basically, it links the button enablement directly to the checkbox value, which is the conventional way of presenting a license agreement in a program.

 

Always put lots of comments in your code and make sure they are perrfectly consistant. That way the program code will still make sense to you years after you made it. Also, with lots of consistant commenting, other people who work on the project will be able to understand it more easily.

As much as I hate to agree with Cerb, this is true, especially if you plan on taking any future programming courses.

 

May I ask how you're handling the actual installation? We never covered it in my VB class and I'll probably need to know for when I finish the game I'm making.

user posted image

Thanks -shaDow

Link to comment
Share on other sites

Well i have sort of put it on hold. I am currently having to do alot of coursework at school (god damn GCSE's). Anyway i am expecting to carry on with the project in about a week.

user posted image
user posted image
R.I.P. Chi Shingi Meiyo

 

21/09/2005 - 07/03/2007

Andolini Mafia Family

 

16/08/2008 - Current

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.