Multiply the Scroll Bar value by text value

choudhmh
02-09-2008, 09:15 AM
Hi guys,
I'm using a scroll bar to increase values of numbers drawn using segments.
What i want is the value from the scroll to increase in mubers which is set by the text value. So when i scroll the scrollbar the values should move up by text value i.e. 2. I have thsi code but keep on getting errors - any help will be apprechiated.
Thanks:

Private Sub HScroll1_Change()
Dim txtToDisplay As String

txtToDisplay = (Format(HScroll1.Value / 100, "000.00") * text2.text)

ConverDigitToLCD Mid(txtToDisplay, 1, 1), Digit1
ConverDigitToLCD Mid(txtToDisplay, 2, 1), Digit2
ConverDigitToLCD Mid(txtToDisplay, 3, 1), Digit3

ConverDigitToLCD Mid(txtToDisplay, 5, 1), Digit5
ConverDigitToLCD Mid(txtToDisplay, 6, 1), Digit6

Text1.Text = txtToDisplay


End Sub

the master
02-09-2008, 03:25 PM
You have to perform the calculation before you format it. You also need to get the value using val() of the text box because the .text property is a string value.

These 2 lines should both work but it depends on whether or not you want to times by text2.text before or after you divide by 100


txtToDisplay = Format((HScroll1.Value / 100) * val(text2.text), "000.00")

txtToDisplay = Format((HScroll1.Value * val(text2.text)) / 100, "000.00")


Edit: Duh! They both work exactly the same!

choudhmh
02-09-2008, 05:04 PM
Fantastic, it wroks perfectly.
Thanks

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum