How to automatically update temperature on the form load?

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2007
Posts: 5
Reputation: newb_smarthome is an unknown quantity at this point 
Solved Threads: 0
newb_smarthome newb_smarthome is offline Offline
Newbie Poster

How to automatically update temperature on the form load?

 
0
  #1
Oct 4th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 645
Reputation: binoj_daniel is an unknown quantity at this point 
Solved Threads: 17
binoj_daniel's Avatar
binoj_daniel binoj_daniel is offline Offline
DaniWeb Expert

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

 
0
  #2
Oct 4th, 2007
Where are you reading the temperature from?
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 5
Reputation: newb_smarthome is an unknown quantity at this point 
Solved Threads: 0
newb_smarthome newb_smarthome is offline Offline
Newbie Poster

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

 
0
  #3
Oct 5th, 2007
i'm using microcontroller pic16f877a to read the temperature...
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 645
Reputation: binoj_daniel is an unknown quantity at this point 
Solved Threads: 17
binoj_daniel's Avatar
binoj_daniel binoj_daniel is offline Offline
DaniWeb Expert

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

 
0
  #4
Oct 5th, 2007
What happens when you use the same code in VB.NET?
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 5
Reputation: newb_smarthome is an unknown quantity at this point 
Solved Threads: 0
newb_smarthome newb_smarthome is offline Offline
Newbie Poster

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

 
0
  #5
Oct 5th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 645
Reputation: binoj_daniel is an unknown quantity at this point 
Solved Threads: 17
binoj_daniel's Avatar
binoj_daniel binoj_daniel is offline Offline
DaniWeb Expert

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

 
0
  #6
Oct 5th, 2007
try this instead:

System.Windows.Forms.Application.DoEvents()
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 5
Reputation: newb_smarthome is an unknown quantity at this point 
Solved Threads: 0
newb_smarthome newb_smarthome is offline Offline
Newbie Poster

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

 
0
  #7
Oct 6th, 2007
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?
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 645
Reputation: binoj_daniel is an unknown quantity at this point 
Solved Threads: 17
binoj_daniel's Avatar
binoj_daniel binoj_daniel is offline Offline
DaniWeb Expert

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

 
0
  #8
Oct 8th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 5
Reputation: newb_smarthome is an unknown quantity at this point 
Solved Threads: 0
newb_smarthome newb_smarthome is offline Offline
Newbie Poster

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

 
0
  #9
Oct 10th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 645
Reputation: binoj_daniel is an unknown quantity at this point 
Solved Threads: 17
binoj_daniel's Avatar
binoj_daniel binoj_daniel is offline Offline
DaniWeb Expert

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

 
0
  #10
Oct 11th, 2007
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 3298 | Replies: 9
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC