Thursday, October 21, 2010

How do you disable a button on vb.net after an amount of clicks?

I need to be able to disable a button after 15 clicks on vb.net. does anyone have a clue?

also, does anyone know how to create a log in system in vb.net which is connected to MS access. i have a connection so i can enter data into a database but i don't have a clue how to make a log in system for it.



any info is good!How do you disable a button on vb.net after an amount of clicks?
Or for something easy you could make a label and then do this for the button click



Private Sub Command1_Click()

If Label1.Caption %26gt;= Val(15) Then

Command1.Enabled = False

Else

Label1.Caption = Label1.Caption + Val(1)

End If

End Sub



Private Sub Form_Load()

Label1.Caption = ';0';

End SubHow do you disable a button on vb.net after an amount of clicks?
First of all I'll assume that,'; You're trying to mute a button after every 15th use in an application launch.



see set up a counter in the coding part of your button click event.

Now check whether the counter reached the target(ie.,15)

if so then '; Disable the button or Make it invisible';.

Otherwise Increment the counter by 1.



I think it's wise enough if the problem is assumed to be..

______________________________________鈥?br>


Secondly I consider that you need to deactivate the button after 15th use in the whole lifetime of the application.. If this is the case.



Then you gotta need to count the clicks and store it in a Text file or in your access data base [ You perhaps know that a log file is nothing but a text file ].



See creating and updating files is a very simple process..

And also you already have an database in active so It's also a easiest method..



If your problem is of the first case then don't think of the file or database...

In the second case I suggest you better to go for a DLL file...
You need to create an integer variable that will be used as a counter in the buton click event handler.

Each time this event is fired you increment this value by one. When it reaches your target number of clicks you then set the buttons enabled property to false.



The trick to making this work is how the counter variable is dimensioned. It must be DIM'ed using the key word STATIC otherwise the value is erased each time that code segment finishes and leave the click event. Using STATIC tells VB to keep the variable and its contents for later use.



DIM STATIC myCount as Integer
Incidentally, unequivocally i do

No comments:

Post a Comment