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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ruler or length Picker

Status
Not open for further replies.

oxicottin

Programmer
Jun 20, 2008
353
US
Hello, I am in the need of a popup picker that would select two lengths in 1/32" increments up to 4" but show 1/16,1/8,1/4 ect.

Example:

If I had a slider on the top and a text box in the center and a slider on the bottom and I slid the top slider to 1-1/32" and then slid the bottom slider to 1-1/16" tick OK and in my text box it would show...

1-1/32" - 1-1/16"

I found a time slider similar to what I want but how do I change it from time to length.....

Thanks!

Thanks,
SoggyCashew.....
 
You can create your own. Add two rectangles (Slider1 and Slider2) and two vertical lines (Indicator1 and Indicator2) to a form with a text box txtMeasure. As your mouse moves from left to right over the Slider rectangles, the value in txtMeasure will change accordingly. It doesn't make any difference how wide the boxes are. The code might need to be modified a bit to get to 4.

[pre]
Indicator1
|
V
+-|----------------------------------+
| | Slider1 |
+-|----------------------------------+[/pre]

Code:
Option Compare Database
Option Explicit

Private Sub slider1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Me.Indicator1.Left = Me.slider1.Left + X
    FilltxtMeasure
End Sub

Private Sub Slider2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Me.Indicator2.Left = Me.Slider2.Left + X
    FilltxtMeasure
End Sub
Sub FilltxtMeasure()
    Me.txtMeasure = ConvertTo32nds((Me.Indicator1.Left - Me.slider1.Left) / Me.slider1.Width * 4) & " - " & _
        ConvertTo32nds((Me.Indicator2.Left - Me.Slider2.Left) / Me.Slider2.Width * 4)
End Sub
Public Function ConvertTo32nds(dblValue As Double) As String
    Dim lngWhole As Long
    Dim dblRemainder As Double
    Dim int32nds As Integer
    lngWhole = Int(dblValue)
    dblRemainder = dblValue - lngWhole
    int32nds = Int(dblRemainder * 32)
    ConvertTo32nds = CStr(lngWhole) & "-" & CStr(int32nds) & "/32"
End Function

Duane
Hook'D on Access
MS Access MVP
 
Duane that worked great but im having trouble if I mouse into the slider. If you mouse into the slider it stops moving but if you just follow the edge of the slider then it works perfect. Is there a way I can use the Active X slider?

Thanks,
SoggyCashew.....
 
The solution I suggested worked for me.

You can possibly use a slider control but I'm not sure how it handles fractions/decimals. You might need 4 slider controls to capture the whole numbers and then the 32nds.

Duane
Hook'D on Access
MS Access MVP
 
Duane I figured out why it wasnt working I had the box set to transparent..... LOL it works now! Either way I can make this sit ontop a slider image to look better or even a ruler.

Thanks again!

Thanks,
SoggyCashew.....
 
Duane, I been goofing with this thing since yesterday and I have been woundering how I can change a few things and I been having a few problems with when I open the picker it isnt showing the number that is in the textbox if there already is one. What I dont like and would like to change is I need to press down on the button to move the indicator to be more accurate because mousing in and out is dificult since im trying to get a measurement in 1/32" so how can I acomplish this? Also, how can I show the number thats already in the txtMeasuremnt box on the main form in the pop up if there is one?

MY FULL EXAMPLE .MDB


Thanks


Thanks,
SoggyCashew.....
 
I'm not sure I have time to figure everything out for you especially since the scope is increasing and you have described how you want to use this as a pop-up.

You should be able to set the position of the line in the On Open event of the pop-up. It's just math.

If you can't figure this out, use 2 pairs of slider controls. One for whole numbers and the other for 32nds.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top