Computing.Net > Forums > Programming > Easy VB6 question..respond asap pls

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Easy VB6 question..respond asap pls

Reply to Message Icon

Name: Danny
Date: January 29, 2003 at 21:29:14 Pacific
OS: Windows 2000 Professional
CPU/Ram: Pentium 4/2.2Ghz w/512pc2
Comment:

Hey guys, this is my first post here. I'm a newbie to Visual Basic in general and I need help with a very simple thing, I just can't quite figure it out on my own. I'm making a small program that consists of 1 picture box and 1 command box. When I click the command box it says "Hey guys" in the picture box. Now I have all of it up to here, but when I keep clicking the command button it keeps printing "Hey guys" in the picture box. What is the code for making it say it once, meaning even if I click the command button 300 times it will only print "Hey guys" once in the picture box. Thanks guys, a quick response would be appreciated.



Sponsored Link
Ads by Google

Response Number 1
Name: borelli34
Date: January 29, 2003 at 23:33:16 Pacific
Reply:

There is problably a number of ways to do this but the most straight forward to me would be to create a boolean variable, initialize it to true and then set it to false when ever the command button is pressed. Finally, only allow the text to be sent/updated to the picture box when the boolean variable is true. To make it easy to recognize or remember you may want to call it something like FirstTime or something similar. In other words, use a boolean variable to track when the first time the button is clicked was and change that variable within the onclick method for the command button. Use the value of the boolean variable to determine if it is the first time through or not and go from their.

borelli34@cox.net


0

Response Number 2
Name: George
Date: January 30, 2003 at 07:31:30 Pacific
Reply:


In your "on-click" event
Clear the contents of your picture box
then print "Hey Guy's"

No matter how many times you click the button "Hey Guy's" will only show up once.

George


0

Response Number 3
Name: dizz
Date: January 30, 2003 at 09:56:37 Pacific
Reply:

To: Borelli, I don't know what you're talking about, boolean variables and such, I'm a newbie. And to George, can you be more specific, it is sort of vague. Guys there is a much easier way to do this. It's simple, I just forgot the code, it's something with .Cls (ClearScreen)


0

Response Number 4
Name: sp
Date: January 30, 2003 at 12:52:07 Pacific
Reply:

hey danny

here is a very easy way
when the button is pressed
write the last line something like this

command1.enabled=false

And the user wont be able to press it more
than 1 time

Simple righ


0

Response Number 5
Name: borelli34
Date: January 30, 2003 at 14:20:24 Pacific
Reply:


========================================================================================
Danny,

Sorry, about that. It can be easy to make certain assumptions sometimes. A boolean variable is a variable that can be one of only two values. Either true or false. As to clearing the contents of your picture box, that can create flicker and is a bad habit to get into programming wise. Besides, SP has the best (and most professional way) to do it. The line SP suggested (command1.enabled=false) will disable the command button after its first use as long as it is placed at the end of the on-click method. By the way, to get to the code for the on-click method simply double click the command button within the form disigner and it will jump you to the newly created on-click procedure for that command button.

borelli34@cox.net

========================================================================================


0

Related Posts

See More



Response Number 6
Name: dizz
Date: January 30, 2003 at 14:42:39 Pacific
Reply:

Guys, I don't want to lock the command button. I want to continue to press the command button, but the contents in the picture box will only appear once. I said it twice already, it has to do with .CLS (clear screen) Something like that. Again, I do not want to lock the command button, I want to be able to click it a hundred times and the contents in the picture box to only appear once. Thanks everyone.


0

Response Number 7
Name: HiJinx
Date: January 30, 2003 at 15:15:17 Pacific
Reply:

Following is code for using either borelli's boolean idea or using the .cls that you mentioned:


Private Sub Command1_Click()

Static flgPrinted As Boolean

If flgPrinted = False Then
Picture1.Print "text"
flgPrinted = True
End If

End Sub

Private Sub Command1_Click()

Picture1.Cls
Picture1.Print "text"

End Sub


0

Response Number 8
Name: dizz
Date: January 30, 2003 at 17:12:34 Pacific
Reply:

Private Sub Command1_Click()

Picture1.Cls
Picture1.Print "text"

End Sub

That's all I wanted! Thanks a bunch HiJinx!


0

Sponsored Link
Ads by Google
Reply to Message Icon

What is wrong with this A... Playing a CD clip on an h...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Easy VB6 question..respond asap pls

easy VB6 questions www.computing.net/answers/programming/easy-vb6-questions/5807.html

An easy VB6 question? Maybe!!! www.computing.net/answers/programming/an-easy-vb6-question-maybe/6218.html

Simple VB6 question www.computing.net/answers/programming/simple-vb6-question/14752.html