|
-
Jun 15th, 2000, 10:13 AM
#1
Thread Starter
Addicted Member
I Have tried and tried to make this simple program just
change the text in a textbox with one command button..but i am out of ideas..and i dont know too much about vb to try functions or moduels.It seems so simple to figure out...but yet i cant..
I have a text box and one command button.....i want to be bale to change the text message when i click the command button....
I have tried suggestions that many members here have gave me...like making a pause moduel...but that would do it..but it isnt how i want to do it.
Select case doesnt work either..Or If then's either..
I can get my idea to work to change one message to another but then i am out of ideas...here is my code again..
Private Sub Form-load()
Text1.Text = "Message" 'displays the message when it runs
End Sub
Private Sub Command1_Click()
Dim Message1 As String
Message1 = "Whatever" 'this displays 2 message just fine
Text1.Text = Message1
End Sub
BUT!! as soon as i try to place something like
Text1.Text = " " To clear the textbox in the same command1 code..and then if i run the program and i click the command button
it erases the message and i am stuck!!!!
Is there any code that i can use to display the second message and then still clear the message and display another message with one command button????????????????
I dont want to have to use a timer for a little form like this...i dont think it is called for i think there is something else i could use..
Any help would be greatly appreciated...even if you tell me i cant make this with out a function or something .
Thank you.
NeWbIe vbeer6.0()
Working model editon...haha!!!!
End Sub
-
Jun 15th, 2000, 10:54 AM
#2
PowerPoster
GetTickCount API
Hope this is what you want...
The following example will change the Text1 textbox content every 3 seconds.
Code:
Option Explicit
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub Command1_Click()
Dim t1 As Long
Dim t2 As Long
Dim Cnt As Integer
Dim Message1 As String
Message1 = "Whatever"
Text1.Text = Message1
Cnt = 0
Do Until Cnt > 10
t1 = GetTickCount
t2 = 0
While t2 - t1 < 3000
DoEvents
Text1.Text = "Message " & Cnt
t2 = GetTickCount
Wend
Cnt = Cnt + 1
Loop
End Sub
-
Jun 15th, 2000, 11:40 AM
#3
Fanatic Member
Well...
Well,
to do like your wish, I think you need to generate a module / function, like what we called with Delay or Wait Function.
I think I've ever read such function like that. But I've forgotten. VB provides you with such function like that. But, since I've forgotten what I've read couple of months before, Just try to make a looping as your Delay / wait manual function.
try this, hope will work.
private sub command1_click()
message = "Message before delay..."
do while i<=3000 'the max. time you want to have.
i = i + 1 'or whatever increament you want to make.
loop
message = ""
do while i<=3000 'the max. time you want to have.
i = i + 1 'or whatever increament you want to make.
loop
message = "Message after twice loop..."
end sub
Cheers,
Wen Lie
-
Jun 15th, 2000, 11:59 AM
#4
New Member
I know you said if-thens wouldn't work, but were you using a global variable which you could increment each time the command button was pressed, such as
Dim counter
Private Sub Command1_Click
counter = counter + 1
If counter = some_value
do_something
Else if counter = something_else
do_something_else
.
.
.
.
or is this what you tried already?
-
Jun 15th, 2000, 12:38 PM
#5
Fanatic Member
Try this...
Well,
Try to use Kernel32, WinAPI Library.
At your coding,
First, try to declare WinAPI Kernel32
And then at your code :
Private Sub Form_Load()
Message = "Bla bla bla... Before Click Command Button"
End Sub
Private Sub Command1_Click()
Sleep(5000)
Message = ""
Sleep(3000)
Message = "Bla bla bla... After Click Command Button"
End Sub
Cheers,
Wen Lie
-
Jun 15th, 2000, 01:31 PM
#6
Thread Starter
Addicted Member
Thanks everyone..
Thanks for all your help...but i see now that should stop trying to learn the advanced stuff before i learn the basics..
Most of the code that was placed here i dont completly understand! .....gotta learn to walk before i can run!!
This simple little program wasnt so simple after all!haha
Well thanks again :0)
NewBee Vbeer6.0()
Using Working model edition!!! haha
End Sub
-
Jun 17th, 2000, 09:13 AM
#7
Fanatic Member
Let me get this right?
I think we misunderstood the question
You simple want to change the text to whatever when the command is clicked (which worked okay - you say)and the problem your having is that when you put the code to clear the textbox it messed things up?
If that is the question then you need to move the line of code that clears the textbox, to before you actually set the textbox text
Private Sub Command1_Click()
Dim Message1 As String
Text1.Text = "" 'clear textbox here
Message1 = "Whatever" 'this displays 2 message just fine
Text1.Text = Message1
End Sub
-
Jun 17th, 2000, 09:28 AM
#8
Hyperactive Member
How about a random text input?
Use randomize
form load
textbox.text = ""
'clear the textbox
Command click()
dim str1, str2, str3 as string 'declare the text as string variables
str1="first message"
str2= "second message"
str3 = "str.message"
Dim myValue as integer
Randomize 'initialize the random number generator
MyValue = Int((3 Rnd) + 1)
Select Case MyValue
Case is 1
txtInput.text = str1
Case is 2
txtInput.text = str2
Case else
txtInput.text = str3
End Select
End Sub
"Should do the trick"
 Mahalo 
VB6(SP5), VC++, COBOL, Basic, JAVA
MBA, MCSD, MCSE, A+
Computer Forensics
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|