473,320 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Wait command in visual basic 2005

I have just started learning visual basic 2005. I tried entering the command: Wait(1000) in order for the program to wait for 1 second before proceeding, but it rejected this saying Wait wasn't defined. How do I enter a pause between lines of code? Since I'm very new to visual basic, I would like to be able to follow things along on the screen without them whizzing right by.Thank you!
Sep 7 '07 #1
4 11162
Expand|Select|Wrap|Line Numbers
  1.  
  2. System.Threading.Thread.Sleep(1000) will put the machine to sleep for 1 sec.
  3.  
Sep 7 '07 #2
Sorry to bother, but I tried the sleep threading method you provided, and it doesn't work. It also makes it impossible to stop the program without going back to the debug panel and selecting the stop square button.

Here is the code its in. I inserted a single quotation mark to indicate the step following is to implement the wait function, then I tried inserting your bid of code to sleep and set the time for 5000 milliseconds. It doesn't appear to be in the correct location, but as a new person, it seemed a logical point to place it for me. If you have a suggestion, I would sincerely appreciate it. My program was taken off the net and reads a temperature sensor connected to the serial port. The sensor outputs data continuously, and all I do is read it. I just don't need to keep reading it so often - hence the need for a wait / sleep delay between reading and writing to the text box. Thanks for your help!

Private Sub AccessForm(ByVal action As String, ByVal formText As String, ByVal textColor As Color)

Select Case action

' Select an action to perform on the form.
' (Can add more actions as needed.)

Case "AppendToMonitorTextBox"

'implement a wait function

System.Threading.Thread.Sleep(5000)

' Append text to the rtbMonitor textbox using the color for received data.

rtbMonitor.SelectionColor = colorReceive
rtbMonitor.AppendText(formText)


'Return to the default color.

rtbMonitor.SelectionColor = colorTransmit

' Trim the textbox's contents if needed.

If rtbMonitor.TextLength > maximumTextBoxLength Then

TrimTextBoxContents()

End If

Case "DisplayStatus"

' Add text to the rtbStatus textbox using the specified color.

DisplayStatus(formText, textColor)

Case "DisplayCurrentSettings"

' Display the current port settings in the ToolStripStatusLabel.

DisplayCurrentSettings()

Case Else

End Select

End Sub
Sep 7 '07 #3
This is what I use, and always works fine for me

Expand|Select|Wrap|Line Numbers
  1.     Public Sub Wait(ByVal Milliseconds As Integer)
  2.         Dim time As Date
  3.         time = Now.AddMilliseconds(Milliseconds)
  4.         Do While time > Now
  5.             Application.DoEvents()
  6.         Loop
  7.     End Sub
  8.  
Sep 7 '07 #4
Awesome! Dude you awesome this great!!
Sep 29 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: DaVBGuy | last post by:
I'm currently using VB 6 for windows based apps. Should I make the jump to VS.2003 now, or should I wait till (the final) VS.2005 release comes out later this year. If I have not started...
10
by: jfathman | last post by:
Hello, I am thinking of spending some holiday time reading the third edition of Programming C# by Jesse Liberty, using Visual C# .Net Standard 2003. But I see at www.oreilly.com that a new...
2
by: paul | last post by:
I have a file type that is going to be associated with my visual basic application and i want the user to be able to double click on a file of said type and have it launch the program and load the...
2
by: elnahrawi | last post by:
Download ebook http://books-download.com/?Book=1487-Visual+Basic+2005+Jumpstart Okay, all you VB6 developers--time's up. As of March 2005, Microsoft no longer supports this version of Visual...
6
by: Carol | last post by:
Hi. When I try to run Visual Studio 2003 I get the message "MS development environment is not installed for the current user. Please run setup to install the application." Is there any way to...
97
by: Master Programmer | last post by:
An friend insider told me that VB is to be killled off within 18 months. I guess this makes sence now that C# is here. I believe it and am actualy surprised they ever even included it in VS 2003 in...
2
by: Milan | last post by:
Hi, Please guide me how to set command line argument and how to retrive command line argument. Senario: vb.net application should be able to execute from command prompt by passing login and...
11
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I have seen the terms Visual Basic 2005 and VB.NET. It seems that sometimes they seem to be referring to the same thing but sometimes they are not. I also run into terms like VB9 and VB10.
7
by: Jwe | last post by:
Hi, I've written a program which has both a command line interface and Windows form interface, however it isn't quite working correctly. When run from command line with no arguments it should...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.