i want to display graph that will access the start time and end time from text boxes. i am using timer to plaot the graph.. how do i do it?? in short how do i assign the value from text boxes to graph at run time. the graph is displayed on command button click
urgent need
Collapse
X
-
in order for us to help you, please submit some of your code, or a modified sample, with what you're trying to do. especially the method for displaying the graph.Originally posted by suvarnai want to display graph that will access the start time and end time from text boxes. i am using timer to plaot the graph.. how do i do it?? in short how do i assign the value from text boxes to graph at run time. the graph is displayed on command button click -
i am using the following code but now i don know how to display the line on the pic box at run time using timer. the timer strt time shud be from text box1 and end time from text box2. plz guide..Originally posted by BlackMustardin order for us to help you, please submit some of your code, or a modified sample, with what you're trying to do. especially the method for displaying the graph.
Code:Private Scroll_Factor As Long Private CurrX As Long Private CurrY As Long Private IncY As Single Private PrevX As Long Private PrevY As Long Private OffsetX As Integer Private OffsetY As Integer Private WindowX As Integer Private WindowY As Integer Private GraphScaleX As Integer Private GraphArray() As String Private GraphArrayCount As Long Private GraphMargin As Long Private Sub Form_Load() 'On Error GoTo errorhandler HScroll1.Min = 0 HScroll1.Max = ScaleX(PicGraph1.Width, 8, vbTwips) - PicGraph2.Width HScroll1.LargeChange = 10 * Screen.TwipsPerPixelX HScroll1.SmallChange = Screen.TwipsPerPixelX VScroll1.Min = 0 VScroll1.Max = ScaleY(PicGraph1.Height, 8, vbTwips) - PicGraph2.Height VScroll1.LargeChange = 10 * Screen.TwipsPerPixelY VScroll1.SmallChange = Screen.TwipsPerPixelY Me.WindowState = 2 'Me.Caption = Caption OffsetX = ScaleX(20, vbPixels, vbTwips) OffsetY = ScaleY(15, vbPixels, vbTwips) IncY = 0 WindowX = ScaleX(610, vbPixels, vbTwips) WindowY = ScaleY(260, vbPixels, vbTwips) CurrX = OffsetX CurrY = OffsetY PrevX = OffsetX PrevY = OffsetY PicGraph2.Visible = True PicGraph2.Line (OffsetX, OffsetY)-(WindowX, OffsetY), vbBlue PicGraph2.Line (OffsetX, OffsetY)-(OffsetX, WindowY), vbBlue PicGraph2.Line (WindowX, OffsetY)-(WindowX, WindowY), vbBlue PicGraph2.Line (OffsetX, WindowY)-(WindowX, WindowY), vbBlue PicGraph2.AutoRedraw = False GraphMargin = ScaleX(1, vbPixels, vbTwips) bGUILoaded = True Exit Sub 'errorhandler: 'MsgBox ("Error" & Err.Number) End Sub Public Sub UpdateGUI() CurrX = (ScaleX(CLng(Text1.Text), vbPixels, vbTwips) / ScaleX(GraphScaleX, vbPixels, vbTwips) + OffsetX) CurrY = (CLng(IncY) + OffsetY) PicGraph1.Line (PrevX, PrevY)-(CurrX + 1, CurrY + 1), vbCyan IncY = IncY + 1 PrevX = (CurrX) PrevY = (CurrY) PicGraph2.PaintPicture PicGraph1.Image, OffsetX + GraphMargin, OffsetY + GraphMargin, _ WindowX - OffsetX - GraphMargin, WindowY - OffsetY - GraphMargin, _ -HScroll1.Value + OffsetX, -VScroll1.Value + OffsetY, _ WindowX - OffsetX, WindowY - OffsetY 'UpdateCmbPeakValue End Sub Private Sub HScroll1_Change() PicGraph2.PaintPicture PicGraph1.Image, OffsetX + GraphMargin, OffsetY + GraphMargin, _ WindowX - OffsetX - GraphMargin, WindowY - OffsetY - GraphMargin, _ -HScroll1.Value + OffsetX, -VScroll1.Value + OffsetY, _ WindowX - OffsetX, WindowY - OffsetY End Sub Private Sub HScroll1_Scroll() PicGraph2.PaintPicture PicGraph1.Image, OffsetX + GraphMargin, OffsetY + GraphMargin, _ WindowX - OffsetX - GraphMargin, WindowY - OffsetY - GraphMargin, _ -HScroll1.Value + OffsetX, -VScroll1.Value + OffsetY, _ WindowX - OffsetX, WindowY - OffsetY End Sub 'Private Sub PicGraph1_Click() 'Visible = True 'PicGraph2.Visible = False 'End Sub ' 'Private Sub PicGraph2_Click() 'Visible = True 'PicGraph1.Visible = False 'End Sub Private Sub Timer1_Timer() Visible = False If Interval > 0 Then ' Start the timer. For Timer1.Interval = 1000 To Timer1.Interval = 7000 Timer1.Enabled UpdateGUI Else ' Stop the timer. Timer1.Interval = 10 End If End Sub Private Sub VScroll1_Change() PicGraph2.PaintPicture PicGraph1.Image, OffsetX + GraphMargin, OffsetY + GraphMargin, _ WindowX - OffsetX - GraphMargin, WindowY - OffsetY - GraphMargin, _ -HScroll1.Value + OffsetX, -VScroll1.Value + OffsetY, _ WindowX - OffsetX, WindowY - OffsetY End Sub Private Sub VScroll1_Scroll() PicGraph2.PaintPicture PicGraph1.Image, OffsetX + GraphMargin, OffsetY + GraphMargin, _ WindowX - OffsetX - GraphMargin, WindowY - OffsetY - GraphMargin, _ -HScroll1.Value + OffsetX, -VScroll1.Value + OffsetY, _ WindowX - OffsetX, WindowY - OffsetY End SubComment
-
cud u please help me out with this... i have given the code tht i have used..Originally posted by BlackMustardin order for us to help you, please submit some of your code, or a modified sample, with what you're trying to do. especially the method for displaying the graph.Comment
-
i think you're using the timer control in a wrong way - the properties should be used as follows:Originally posted by suvarnacud u please help me out with this... i have given the code tht i have used..
[code=vb]with timer1
.enabled = true ' turns timer on (value false would turn off)
.interval = 1000 ' sets timer interval to 1 second (value in milliseconds). this is how often the timer will "tick" and raise the timer1_timer event
end with[/code]
to use this with values from textboxes, i would recommend storing those values in variables (after checking that the input is valid), and then use a stepping variable to increment between the textbox values. an example of how this could be done:
[code=vb]
dim endvalue, valuenow, step as integer
sub Initiate()
' before doing this you should really check that the text value is an integer, to avoid type mismatch error
valuenow = textbox1.text
endvalue = textbox2.text
step = 1 ' this is the amount the value will increase with each tick of the timer
end sub
sub Timer1_Timer()
' This sub handles what will happen every time the timer ticks.
valuenow = valuenow + step
if valuenow >= endvalue then ' the value has been reached
Timer1.enabled = false ' stop the timer
exit sub ' abort the procedure
end if
' Insert the code to update your picture here
end sub
sub Command1_Click( )
Timer1.Enabled = Not Timer1.Enabled ' toggles whether the timer is enabled or not
end sub[/code]
modify this code to suit your needs, and get back if you experience more problems. but remember - very few of the people here are full-time support coders. i'll get back to you as soon as i can, but it might be a few days...Comment
-
Originally posted by BlackMustardi think you're using the timer control in a wrong way - the properties should be used as follows:
[code=vb]with timer1
.enabled = true ' turns timer on (value false would turn off)
.interval = 1000 ' sets timer interval to 1 second (value in milliseconds). this is how often the timer will "tick" and raise the timer1_timer event
end with[/code]
to use this with values from textboxes, i would recommend storing those values in variables (after checking that the input is valid), and then use a stepping variable to increment between the textbox values. an example of how this could be done:
[code=vb]
dim endvalue, valuenow, step as integer
sub Initiate()
' before doing this you should really check that the text value is an integer, to avoid type mismatch error
valuenow = textbox1.text
endvalue = textbox2.text
step = 1 ' this is the amount the value will increase with each tick of the timer
end sub
sub Timer1_Timer()
' This sub handles what will happen every time the timer ticks.
valuenow = valuenow + step
if valuenow >= endvalue then ' the value has been reached
Timer1.enabled = false ' stop the timer
exit sub ' abort the procedure
end if
' Insert the code to update your picture here
end sub
sub Command1_Click( )
Timer1.Enabled = Not Timer1.Enabled ' toggles whether the timer is enabled or not
end sub[/code]
modify this code to suit your needs, and get back if you experience more problems. but remember - very few of the people here are full-time support coders. i'll get back to you as soon as i can, but it might be a few days...
hey i tried the code but its not displaying nethin...
i used
in place where i ahd to update the picture.Code:PicGraph2.Line (OffsetX, Text1.Text)-(OffsetY, Text2.Text), vbYellow updategui
reply soon plz..Code:the updategui code is as follows Public Sub UpdateGUI() CurrX = (ScaleX(CLng(Text1.Text), vbPixels, vbTwips) / ScaleX(GraphScaleX, vbPixels, vbTwips) + OffsetX) CurrY = (CLng(IncY) + OffsetY) PicGraph2.Line (PrevX, PrevY)-(CurrX + 1, CurrY + 1), vbYellow IncY = IncY + 1 PrevX = (CurrX) PrevY = (CurrY) PicGraph1.PaintPicture PicGraph2.Image, OffsetX + GraphMargin, OffsetY + GraphMargin, _ WindowX - OffsetX - GraphMargin, WindowY - OffsetY - GraphMargin, _ -HScroll1.Value + OffsetX, -VScroll1.Value + OffsetY, _ WindowX - OffsetX, WindowY - OffsetY 'UpdateCmbPeakValue End SubComment
Comment