VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This code takes values entered into a textbox enters them into a listbox and then plots them on a l

by Best Programmer (4 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Thu 24th May 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This code takes values entered into a textbox enters them into a listbox and then plots them on a line Graph. In this case a Picture box.

API Declarations


'Just add two textboxes: TxtNumber and TxtScore
'Three command buttons: cmdEnter, cmdClear and cmdExit
'Draw a picture box with the dimensions of Height: 2535 and Width of 3015
Dim X As Single, Y As Single
Dim n As Integer
Dim NewPointX As Integer, NewPointY As Integer
Dim LastPointX As Integer, LastPointY As Integer
'and Enjoy

Rate This code takes values entered into a textbox enters them into a listbox and then plots them on a l





Private Sub cmdClear_Click()
  txtNumber = ""
  txtScore = ""
  LineGraph.Cls
  ListScore.Clear
  txtNumber.SetFocus
End Sub

Private Sub cmdClearValues_Click()
  txtScore = ""
  txtNumber = ""
  txtNumber.SetFocus
End Sub

Private Sub cmdEnterData_Click()
  ListScore.AddItem Val(txtNumber) & "   " & Val(txtScore)
  NewPointX = Val(txtNumber) * 50
  NewPointY = 2535 - (Val(txtScore) * 20)
  LineGraph.Line (LastPointX, LastPointY)-(NewPointX, NewPointY)
  LastPointX = NewPointX
  LastPointY = NewPointY
  txtScore = ""
  txtNumber = ""
  txtNumber.SetFocus
  'n = n + 1
End Sub

Private Sub cmdExit_Click()
  End
End Sub

Private Sub Form_Load()
  n = 0
  LastPointX = 0
  LastPointY = 2535
End Sub



Private Sub txtScore_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
    ListScore.AddItem Val(txtNumber) & "   " & Val(txtScore)
    NewPointX = Val(txtNumber) * 50
    NewPointY = 2535 - (Val(txtScore) * 20)
    LineGraph.Line (LastPointX, LastPointY)-(NewPointX, NewPointY)
    LastPointX = NewPointX
    LastPointY = NewPointY
    txtScore = ""
    txtNumber = ""
    txtNumber.SetFocus
    n = n + 1
  End If
End Sub


Download this snippet    Add to My Saved Code

This code takes values entered into a textbox enters them into a listbox and then plots them on a l Comments

No comments have been posted about This code takes values entered into a textbox enters them into a listbox and then plots them on a l. Why not be the first to post a comment about This code takes values entered into a textbox enters them into a listbox and then plots them on a l.

Post your comment

Subject:
Message:
0/1000 characters