Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VScroll (or HScroll) - Multiple change events into multiple textboxes? 1

Status
Not open for further replies.

emcc

Programmer
Oct 12, 2001
124
0
0
US
I'm still a newbie at this......

Is it possible to have a scrollbar that puts the value of each change a user makes (ie-each choice they make from the scrollbar) into different textboxes? I'm trying to have the user input three values into three textboxes and then calculate an average of those three values. Right now I'm getting the same value in all three boxes...

Any help would be greatly appreciated!
 
Start a new Project. On the blank form place a textbox control. Copy it and paste two more. WHen prompted to make Text1 a control array select "Yes". Place a Horizintal scroll bar on the form. Place a label control on the form. Go to the code window and paste the following text, making sure that you over write anything that is already there:

Dim Cur As Integer
Option Explicit

Private Sub HScroll1_Change()
Dim x As Long
Text1(Cur).Text = HScroll1.Value
Cur = Cur + 1
If Cur > 2 Then
x = Val(Text1(0).Text) + Val(Text1(1).Text) + Val(Text1(2).Text)
Label1.Caption = x / 3
Cur = 0
End If
End Sub


Try it.

Hunter
 
Awesome-it works great! Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top