VB6 Forms

I'm working on an application using VB6 that starts up and displays a 'SelectionForm' that contains (3) command buttons. Clicking on any of the command buttons opens up a new form; each of the (3) new forms have an 'Exit' button that hides that particular form and returns to the SelectionForm (by using 'form.show & form.hide').

All works well, except.......

I'd like to have one of the command buttons act as a 'Run Once' button; in other words, it will be enabled until it is picked the first time; then after it's form is displayed and exited, that command button will be disabled and grayed-out on the SelectForm screen.

Seems simple enough, but I've not been able to find the trick to do this yet. Can anyone help?

Thanks!!

Comments

  • : I'm working on an application using VB6 that starts up and displays a 'SelectionForm' that contains (3) command buttons. Clicking on any of the command buttons opens up a new form; each of the (3) new forms have an 'Exit' button that hides that particular form and returns to the SelectionForm (by using 'form.show & form.hide').
    :
    : All works well, except.......
    :
    : I'd like to have one of the command buttons act as a 'Run Once' button; in other words, it will be enabled until it is picked the first time; then after it's form is displayed and exited, that command button will be disabled and grayed-out on the SelectForm screen.
    :
    : Seems simple enough, but I've not been able to find the trick to do this yet. Can anyone help?
    :
    : Thanks!!
    :
    First thing is first: add a module and in the declaration section, add the code:
    [code]
    Global Frm1Ran As Boolean
    Global Frm2Ran As Boolean
    Global Frm3Ran As Boolean
    [/code]

    On the selection form, add the following code under the Form_Load sub:
    [code]
    If Not Frm1Ran = True And Not Frm2Ran = True And Not Frm3Ran = True Then
    Frm1Ran = False
    Frm2Ran = False
    Frm3Ran = False
    End If
    [/code]

    The condition is added to make sure that when the form is reloaded (I can't remember if .Show will trigger the Form_Load event, so it's better to make sure you're prepared incase it does, otherwise what kind of programming help would I be giving you, lol?) the variables all won't be set back to False.

    Now under the code that you use to exit the forms, add:
    (NOTE: formX = current form (ie. if you're working on Form2 then formX = FrmRan2)
    [code]
    formX = True (ie. FrmRan2 = True)
    [/code]

    And for the sake of argument, the selection form's name is frmSelect. Now append the following code on the exit code:
    [code]
    Run.SetButtons
    [/code]

    Run.SetButtons? What the hell does that mean?! Go into the Module and add the code:
    [code]
    Global Run As New Module1
    Sub SetButtons()
    If FrmRan1 = True Then
    frmSelect.Command1.Enabled = False
    ElseIf FrmRan2 = True Then
    frmSelect.Command2.Enabled = False
    ElseIf FrmRan3 = True Then
    frmSelect.Command3.Enabled = False
    End If
    End Sub
    [/code]

    Now the last bit of code you'll add to when the form loads:
    [code]
    formX = True (ie. FrmRan3 = True)
    [/code]

    That should do it. If you have any questions or it doesn't work, drop me an email and I'll actually code it instead of thinking of a solution off the top of my head :P
    [code]<%
    '// Programmed By: Zantos
    '// VisualProgramming.NET
    '// http://vp.funurl.com/
    '// visualprogramming@hotmail.com
    %>[/code]

  • : I'm working on an application using VB6 that starts up and displays a 'SelectionForm' that contains (3) command buttons. Clicking on any of the command buttons opens up a new form; each of the (3) new forms have an 'Exit' button that hides that particular form and returns to the SelectionForm (by using 'form.show & form.hide').
    :
    : All works well, except.......
    :
    : I'd like to have one of the command buttons act as a 'Run Once' button; in other words, it will be enabled until it is picked the first time; then after it's form is displayed and exited, that command button will be disabled and grayed-out on the SelectForm screen.
    :
    : Seems simple enough, but I've not been able to find the trick to do this yet. Can anyone help?
    :
    : Thanks!!
    :

    In the button's click event, disable it and show the form:

    [code]Private Sub Command1_Click()

    Command1.Enabled = False
    Form1.Show

    End Sub
    [/code]

    Thereafter, the button will be disabled and they can't click it.
  • : : I'm working on an application using VB6 that starts up and displays a 'SelectionForm' that contains (3) command buttons. Clicking on any of the command buttons opens up a new form; each of the (3) new forms have an 'Exit' button that hides that particular form and returns to the SelectionForm (by using 'form.show & form.hide').
    : :
    : : All works well, except.......
    : :
    : : I'd like to have one of the command buttons act as a 'Run Once' button; in other words, it will be enabled until it is picked the first time; then after it's form is displayed and exited, that command button will be disabled and grayed-out on the SelectForm screen.
    : :
    : : Seems simple enough, but I've not been able to find the trick to do this yet. Can anyone help?
    : :
    : : Thanks!!
    : :
    :
    : In the button's click event, disable it and show the form:
    :
    : [code]Private Sub Command1_Click()
    :
    : Command1.Enabled = False
    : Form1.Show
    :
    : End Sub
    : [/code]
    :
    : Thereafter, the button will be disabled and they can't click it.
    :
    Whoa, lol, I can't believe I didn't think of that...damn herbal remedies :D

    [code]<%
    '// Programmed By: Zantos
    '// VisualProgramming.NET
    '// http://vp.funurl.com/
    '// visualprogramming@hotmail.com
    %>[/code]

  • Sorry for the delay in getting this message out - the Holidays tend to wreak havoc with schedules!!

    Thanks to all that replied to my query regarding hiding a button after running it once! The solution was very simple and eloquent!

    Thanks again!
  • : Whoa, lol, I can't believe I didn't think of that...damn herbal remedies :D
    :

    It's usually the simple things that get us. We get used to thinking hard and sometimes we think [italic]too[/italic] hard. As an example, I can often do multiplication faster and more accurately in my head than I can addition on paper...
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories