944,124 Members | Top Members by Rank

Ad:
Oct 4th, 2007
0

How to automatically update temperature on the form load?

Expand Post »
Hai,
I'm read temperature data using MSComm..
The temperature was successfully display on vb6..but how can I update/automatically refresh the temperature on web according to current temperature?
could you kindly please help me over here? thks!
Below is my coding:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub Form_Load()
  2. MSComm1.PortOpen = True
  3.  
  4. MSComm1.Output = "temp" + Chr$(13)
  5. 'waits for 5 char to be recieved
  6.  
  7. Do
  8. dummy = DoEvents()
  9. Loop Until MSComm1.InBufferCount >= 20
  10. 'print value in text box
  11. Text1.Text = MSComm1.Input
  12.  
  13. End Sub
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
newb_smarthome is offline Offline
5 posts
since Oct 2007
Oct 4th, 2007
0

Re: How to automatically update temperature on the form load?

Where are you reading the temperature from?
Reputation Points: 25
Solved Threads: 18
Practically a Master Poster
binoj_daniel is offline Offline
645 posts
since Dec 2006
Oct 5th, 2007
0

Re: How to automatically update temperature on the form load?

i'm using microcontroller pic16f877a to read the temperature...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
newb_smarthome is offline Offline
5 posts
since Oct 2007
Oct 5th, 2007
0

Re: How to automatically update temperature on the form load?

What happens when you use the same code in VB.NET?
Reputation Points: 25
Solved Threads: 18
Practically a Master Poster
binoj_daniel is offline Offline
645 posts
since Dec 2006
Oct 5th, 2007
0

Re: How to automatically update temperature on the form load?

when i convert the code into vb.net2003, there was an error on do event() function..how to convert do event function in vb.net2003?
Do
dummy = DoEvents()----this line was error
Loop Until MSComm1.InBufferCount >= 20
'print value in text box
Text1.Text = MSComm1.Input
Reputation Points: 10
Solved Threads: 0
Newbie Poster
newb_smarthome is offline Offline
5 posts
since Oct 2007
Oct 5th, 2007
0

Re: How to automatically update temperature on the form load?

try this instead:

System.Windows.Forms.Application.DoEvents()
Reputation Points: 25
Solved Threads: 18
Practically a Master Poster
binoj_daniel is offline Offline
645 posts
since Dec 2006
Oct 6th, 2007
0

Re: How to automatically update temperature on the form load?

hi,
thanks..it's working! I can display the temperature on my web application...but, how to automatically update temperature on the form load rather than manually clicking the refresh button?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
newb_smarthome is offline Offline
5 posts
since Oct 2007
Oct 8th, 2007
0

Re: How to automatically update temperature on the form load?

What's the code on the refresh button? Currenlty i think you were getting the temp. on the form load also.
You can do this by using a timer control on the form and make the interval "1000" which will be equal to 1 sec. Make the Timer Control Enabled by default, and write the code to refresh temp. in the timer control.
Reputation Points: 25
Solved Threads: 18
Practically a Master Poster
binoj_daniel is offline Offline
645 posts
since Dec 2006
Oct 10th, 2007
0

Re: How to automatically update temperature on the form load?

could you give an examples by using a timer control on the form? i hope i just can refresh the temperature only and not the whole page...

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2. Dim MSComm1 As MSComm
  3. MSComm1 = New MSComm
  4. MSComm1.CommPort = 5 ' select Com1
  5. MSComm1.DTREnable = True
  6. MSComm1.EOFEnable = False
  7. MSComm1.InBufferSize = 1024
  8. MSComm1.InputMode = InputModeConstants.comInputModeText
  9. MSComm1.NullDiscard = False
  10. MSComm1.OutBufferSize = 512
  11. MSComm1.Settings = "38400,n,8,1" ' setting parameter in communicate with com port
  12. MSComm1.InputLen = 6 'define size of Input buffer (comming with Modem)
  13. If MSComm1.PortOpen = False Then
  14. MSComm1.PortOpen = True
  15. Else
  16. MSComm1.PortOpen = False
  17. End If
  18.  
  19. 'MSComm1.PortOpen = False
  20. 'send RD0 command + CR
  21. MSComm1.Output = "temp" + Chr(13)
  22. 'waits for 5 char to be recieved
  23. 'into serial buffer (data + CR)
  24.  
  25. Do
  26. DoEvents()
  27. Loop Until MSComm1.InBufferCount >= 20
  28. 'print value in text box
  29. Label2.Text = MSComm1.Input
Reputation Points: 10
Solved Threads: 0
Newbie Poster
newb_smarthome is offline Offline
5 posts
since Oct 2007
Oct 11th, 2007
0

Re: How to automatically update temperature on the form load?

You can put the same code in the form load on the timer control and it will only refresh the textbox control with the new values. It will not load the form again but yes it redraws the form window. If its a web application you can update a particular without loading the whole page using AJAX.
Reputation Points: 25
Solved Threads: 18
Practically a Master Poster
binoj_daniel is offline Offline
645 posts
since Dec 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: move frame
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: open existing excel file in vba





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC