tags:

views:

21

answers:

1

Can anyone explain why my button keeps launching the associated .BAT file every time I click it, even though I have set it to disabled?

Private Sub TabPage3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage3.Click
    Dim RetBat3

    RetBat3 = Shell("c:\QUEEN ANNES REVENGE\SYSTEM\BAT\UNDO_1.bat", 1)

    Button5.Enabled = False

End Sub
+2  A: 

Because that event handler is tied to TabPage3_Click ?

Its not clear what you're trying to do, but you launch the batch file when TabPage3 is clicked, then disable a button control.

You probably want to remove this TabPage3 click and put the handler on the button instead


You could try adding

if (Button5.Enabled)
{
    Button5.Enabled = False
    RetBat3 = Shell("c:\QUEEN ANNES REVENGE\SYSTEM\BAT\UNDO_1.bat", 1)
}

It feels wrong, but based on the little information you've provided it might fix your immediate issue.

PaulG
Yes but i want the button disabled as soon as the user clicks the tab, another button of the tab named append would make the button available
Mal
as far as i understand the button should be idle and non active if tied to the tabpage3_click this way, Shouldnt it?
Mal
@Mal. Yes, but every time the user clicks the tab page it will launch the script, and then disable the button. I'll add an edit with a fix that might work, but its really hacky.
PaulG
okay i get the idea is there then somthing else i can use to cotrol the buttons being avalable and non avalable for clicking
Mal
A veritable *myriad* of ways sir. Some that may send ecstatic spine tingling waves of logical pleasure. Some that may give cause to nightmares and demonic stares from maintenance programmers. Unfortunately, my only knowledge of your solution is 3 lines in an event handler, so I can't realistically offer any further wisdom.
PaulG