Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
12-Way Converter With Mouse
#1
Here is a 12-way converter app I threw together today, using your mouse.  
Celsius to Farenheit, Farenheit to Celsius, Grams to Ounces, Ounces to Grams, Kilograms to Pounds, Pounds to Kilograms, Kilometers to Miles, Miles to Kilometers, Liters to Gallons, Gallons to Liters, KPH to MPH, and MPH to KPH. 

I tried hard to make it so the 2nd time around in clicking the big buttons you wouldn't need to double click them, but no luck. Probably has to do with the way it handles InputBox$ and MessageBox. Besides that, everything works great. 

(Edited: Spelling Corrections.)

(Code deleted, fixed version posted below.)
Reply
#2
I just fixed some spelling and reposted.
Reply
#3
More spelling corrections, I apologize.
Reply
#4
Wooohooooo! I fixed it so you don't need to double click on a button on the second time around. It was because Windows needing a click in the window, which is strange because the window was already on focus I think. Anyway, I found a work-around using _SCREENCLICK and _SCREENX and _SCREENY. I also added a _DELAY .25 to make it work every time. The delay gives the computer time to get rid of the MessageBox first. I put all of this in a GOSUB/RETURN at the bottom of the program. 

Here is the fixed program: 

(Code deleted, better version below.)
Reply
#5
Forgive me if I overstep here, but this code was just begging to be simplified down into a nice set of repeatable subs and simplified logic.  See if this isn't the *exact* same code as what you wrote, but in a much more modular and expandable way?

Code: (Select All)
'Converter by SierraKen
'Made on August 23, 2025

Screen _NewImage(800, 600, 32)
_PrintString (368, 30), "Converter"

_Title "Converter - by SierraKen"

For x = 1 To 30
    For y = 1 To 30
        c = c + .5
        Line (100 + x, 100 + y)-(300 - x, 150 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'c2f
        Line (100 + x, 175 + y)-(300 - x, 225 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'f2c
        Line (100 + x, 250 + y)-(300 - x, 300 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'g2o
        Line (100 + x, 325 + y)-(300 - x, 375 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'o2g
        Line (100 + x, 400 + y)-(300 - x, 450 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'k2p
        Line (100 + x, 475 + y)-(300 - x, 525 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'p2k
        Line (500 + x, 100 + y)-(700 - x, 150 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'km2m
        Line (500 + x, 175 + y)-(700 - x, 225 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'm2km
        Line (500 + x, 250 + y)-(700 - x, 300 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'l2g
        Line (500 + x, 325 + y)-(700 - x, 375 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'g2l
        Line (500 + x, 400 + y)-(700 - x, 450 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'kmph2mph
        Line (500 + x, 475 + y)-(700 - x, 525 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'mph2kmph
    Next y
Next x

Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
_PrintString (120, 120), "Celsius To Fahrenheit": _PrintString (520, 120), "Kilometers To Miles"
_PrintString (120, 195), "Fahrenheit To Celsius": _PrintString (520, 195), "Miles To Kilometers"
_PrintString (140, 270), "Grams To Ounces": _PrintString (540, 270), "Liters To Gallons"
_PrintString (140, 345), "Ounces To Grams": _PrintString (540, 345), "Gallons To Liters"
_PrintString (120, 420), "Kilograms To Pounds": _PrintString (520, 420), "KM/Hour To Miles/Hour"
_PrintString (120, 495), "Pounds To Kilograms": _PrintString (520, 495), "Miles/Hour To KM/Hour"

mouseWasDown = 0

Do
    Do While _MouseInput: Loop
    xx = _MouseX: yy = _MouseY
    mouseIsDown = -_MouseButton(1)
    If mouseIsDown = 1 And mouseWasDown = 0 Then 'move this outside all those IF conditions
        'Just check if the mouse was properly clicked once.  If it wasn't, nothing else matters.
        Select Case xx 'I prefer select case for ease of organization, as shown here
            Case 100 To 300 'left side of the button list
                Select Case yy
                    Case 100 To 150
                        celsius$ = _InputBox$("Celsius To Fahrenheit", "Enter Celsius Degrees")
                        If Val(celsius$) = 0 And celsius$ <> "0" Then Exit Select
                        ce = Val(celsius$)
                        F = (ce * 1.8) + 32
                        _MessageBox "Fahrenheit", Str$(F), ""
                        RestoreFocus
                    Case 175 To 225
                        Fahrenheit$ = _InputBox$("Fahrenheit To Celsus", "Enter Fahrenheit Degrees")
                        If Val(Fahrenheit$) = 0 And Fahrenheit$ <> "0" Then Exit Select
                        f2 = Val(Fahrenheit$)
                        ce2 = (f2 - 32) / 1.8
                        _MessageBox "Celsius", Str$(ce2), ""
                        RestoreFocus
                    Case 250 To 300: Convert "Grams", "Ounces", 0.35274, "Ounces"
                    Case 325 To 375: Convert "Ounces", "Grams", 28.3495, "Grams"
                    Case 400 To 450: Convert "Kilograms", "Pounds", 2.20462, "Pounds"
                    Case 475 To 525: Convert "Pounds", "Kilograms", 1 / 2.20462, "Kilograms"
                End Select
            Case 500 To 700 'right side of the button list
                Select Case yy
                    Case 100 To 150: Convert "Kilometers", "Miles", 0.621371, "Miles"
                    Case 175 To 225: Convert "Miles", "Kilometers", 1.60934, "Kilometers"
                    Case 250 To 300: Convert "Liters", "Gallons", 0.264172, "Gallons"
                    Case 325 To 375: Convert "Gallons", "Liters", 3.78541, "Liters"
                    Case 400 To 450: Convert "KPH", "MPH", 0.621371, "Miles Per Hour"
                    Case 275 To 525: Convert "MPH", "KPH", 1.60934, "Kilometers Per Hour"
                End Select
        End Select
    End If
    mouseWasDown = mouseIsDown
Loop Until InKey$ = Chr$(27)
System


Sub Convert (from$, to$, multiplier##, long_desc$)
    box_title$ = from$ + " to " + to$
    prompt$ = "Enter " + from$
    user_input$ = _InputBox$(box_title$, prompt$)
    v## = Val(user_input$)
    If v## = 0 And user_input$ <> "0" Then Exit Sub
    _MessageBox long_desc$, Str$(v## * multiplier##), ""
    RestoreFocus
End Sub

Sub RestoreFocus
    _Delay .25
    positionX& = _ScreenX
    positionY& = _ScreenY
    _ScreenClick positionX& + 30, positionY& + 100
End Sub

Instead of copy/pasting all those routines repeatedly and just changing a few parts in them, make them a simple function and just pass them the parts as needed.  Like this, you can easily add any new functionality you'd like into your program as long as it has a simple converted_amount = original_amout * multiplier formula associated to it.  Anything more complex (such as the F2C and C2F formulas), you'd have to calculate separately as I've done here, but for everything else, just let that one simple SUB do all the work for you.

It's dropped several hundred lines out of this code, simplified it, and made it much easier to understand and maintain, in my opinion. Wink

What do you think?  It's still everything you had before; it's just structured to make use of SUBs and FUNCTIONs instead of being so copy/paste orientated.  Wink
Reply
#6
WOW Steve! I feel honored you made this, thank you! Of course, being a BASIC programmer since I was a teenager, I still want to use my own code as an accomplishment (and being disabled myself). But I am honored you made this and I will start learning some of this too, like SELECT CASE which I've only used a couple times ever. I hope this also teaches other people. Smile Thanks Steve! I think I will put both versions on my personal forum section on the same thread. That way people can learn the differences. Does that sound good?
Reply
#7
Sure.  Use as much of it as you like.  I was just wanting to showcase how to modularize your logic and keep it simpler and more reusable for you.  Wink
Reply
#8
Steve, I found something I forgot to add LOL. I forgot to go to Focus (or your RestoreFocus) when a person clicks the Cancel button in the InputBox$. Sorry about that!
Here is your fixed version (I hope). Look at the code and make sure it's correct. I tested it and it seems to work good. I'll post my fixed version after yours. 

Steve's version (fixed): 
Code: (Select All)

'Converter by SierraKen - mod by Steve
'Made on August 23, 2025

Screen _NewImage(800, 600, 32)
_PrintString (368, 30), "Converter"

_Title "Converter - by SierraKen"

For x = 1 To 30
    For y = 1 To 30
        c = c + .5
        Line (100 + x, 100 + y)-(300 - x, 150 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'c2f
        Line (100 + x, 175 + y)-(300 - x, 225 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'f2c
        Line (100 + x, 250 + y)-(300 - x, 300 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'g2o
        Line (100 + x, 325 + y)-(300 - x, 375 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'o2g
        Line (100 + x, 400 + y)-(300 - x, 450 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'k2p
        Line (100 + x, 475 + y)-(300 - x, 525 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'p2k
        Line (500 + x, 100 + y)-(700 - x, 150 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'km2m
        Line (500 + x, 175 + y)-(700 - x, 225 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'm2km
        Line (500 + x, 250 + y)-(700 - x, 300 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'l2g
        Line (500 + x, 325 + y)-(700 - x, 375 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'g2l
        Line (500 + x, 400 + y)-(700 - x, 450 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'kmph2mph
        Line (500 + x, 475 + y)-(700 - x, 525 - y), _RGB32(100 + c, 100 + c, 200 + c), B 'mph2kmph
    Next y
Next x

Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
_PrintString (120, 120), "Celsius To Fahrenheit": _PrintString (520, 120), "Kilometers To Miles"
_PrintString (120, 195), "Fahrenheit To Celsius": _PrintString (520, 195), "Miles To Kilometers"
_PrintString (140, 270), "Grams To Ounces": _PrintString (540, 270), "Liters To Gallons"
_PrintString (140, 345), "Ounces To Grams": _PrintString (540, 345), "Gallons To Liters"
_PrintString (120, 420), "Kilograms To Pounds": _PrintString (520, 420), "KM/Hour To Miles/Hour"
_PrintString (120, 495), "Pounds To Kilograms": _PrintString (520, 495), "Miles/Hour To KM/Hour"

mouseWasDown = 0

Do
    Do While _MouseInput: Loop
    xx = _MouseX: yy = _MouseY
    mouseIsDown = -_MouseButton(1)
    If mouseIsDown = 1 And mouseWasDown = 0 Then 'move this outside all those IF conditions
        'Just check if the mouse was properly clicked once.  If it wasn't, nothing else matters.
        Select Case xx 'I prefer select case for ease of organization, as shown here
            Case 100 To 300 'left side of the button list
                Select Case yy
                    Case 100 To 150
                        celsius$ = _InputBox$("Celsius To Fahrenheit", "Enter Celsius Degrees")
                        If Val(celsius$) = 0 And celsius$ <> "0" Then
                            RestoreFocus
                            Exit Select
                        End If
                        ce = Val(celsius$)
                        F = (ce * 1.8) + 32
                        _MessageBox "Fahrenheit", Str$(F), ""
                        RestoreFocus
                    Case 175 To 225
                        Fahrenheit$ = _InputBox$("Fahrenheit To Celsus", "Enter Fahrenheit Degrees")
                        If Val(Fahrenheit$) = 0 And Fahrenheit$ <> "0" Then
                            RestoreFocus
                            Exit Select
                        End If
                        f2 = Val(Fahrenheit$)
                        ce2 = (f2 - 32) / 1.8
                        _MessageBox "Celsius", Str$(ce2), ""
                        RestoreFocus
                    Case 250 To 300: Convert "Grams", "Ounces", 0.35274, "Ounces"
                    Case 325 To 375: Convert "Ounces", "Grams", 28.3495, "Grams"
                    Case 400 To 450: Convert "Kilograms", "Pounds", 2.20462, "Pounds"
                    Case 475 To 525: Convert "Pounds", "Kilograms", 1 / 2.20462, "Kilograms"
                End Select
            Case 500 To 700 'right side of the button list
                Select Case yy
                    Case 100 To 150: Convert "Kilometers", "Miles", 0.621371, "Miles"
                    Case 175 To 225: Convert "Miles", "Kilometers", 1.60934, "Kilometers"
                    Case 250 To 300: Convert "Liters", "Gallons", 0.264172, "Gallons"
                    Case 325 To 375: Convert "Gallons", "Liters", 3.78541, "Liters"
                    Case 400 To 450: Convert "KPH", "MPH", 0.621371, "Miles Per Hour"
                    Case 275 To 525: Convert "MPH", "KPH", 1.60934, "Kilometers Per Hour"
                End Select
        End Select
    End If
    mouseWasDown = mouseIsDown
Loop Until InKey$ = Chr$(27)
System


Sub Convert (from$, to$, multiplier##, long_desc$)
    box_title$ = from$ + " to " + to$
    prompt$ = "Enter " + from$
    user_input$ = _InputBox$(box_title$, prompt$)
    v## = Val(user_input$)
    If v## = 0 And user_input$ <> "0" Then
        RestoreFocus
        Exit Sub
    End If
    _MessageBox long_desc$, Str$(v## * multiplier##), ""
    RestoreFocus
End Sub

Sub RestoreFocus
    _Delay .25
    positionX& = _ScreenX
    positionY& = _ScreenY
    _ScreenClick positionX& + 30, positionY& + 100
End Sub

Here is my original version (fixed): 

Code: (Select All)

'Converter by SierraKen
'Made on August 23, 2025

Screen _NewImage(800, 600, 32)
_PrintString (368, 30), "Converter"

_Title "Converter - by SierraKen"

'c2f
For x = 1 To 30
    For y = 1 To 30
        c = c + .5
        Line (100 + x, 100 + y)-(300 - x, 150 - y), _RGB32(100 + c, 100 + c, 200 + c), B
    Next y
Next x
Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
_PrintString (120, 120), "Celsius To Fahrenheit"
c = 0

'f2c
For x = 1 To 30
    For y = 1 To 30
        c = c + .5
        Line (100 + x, 175 + y)-(300 - x, 225 - y), _RGB32(100 + c, 100 + c, 200 + c), B
    Next y
Next x
Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
_PrintString (120, 195), "Fahrenheit To Celsius"
c = 0

'g2o
For x = 1 To 30
    For y = 1 To 30
        c = c + .5
        Line (100 + x, 250 + y)-(300 - x, 300 - y), _RGB32(100 + c, 100 + c, 200 + c), B
    Next y
Next x
Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
_PrintString (140, 270), "Grams To Ounces"
c = 0

'o2g
For x = 1 To 30
    For y = 1 To 30
        c = c + .5
        Line (100 + x, 325 + y)-(300 - x, 375 - y), _RGB32(100 + c, 100 + c, 200 + c), B
    Next y
Next x
Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
_PrintString (140, 345), "Ounces To Grams"
c = 0

'k2p
For x = 1 To 30
    For y = 1 To 30
        c = c + .5
        Line (100 + x, 400 + y)-(300 - x, 450 - y), _RGB32(100 + c, 100 + c, 200 + c), B
    Next y
Next x
Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
_PrintString (120, 420), "Kilograms To Pounds"
c = 0

'p2k
For x = 1 To 30
    For y = 1 To 30
        c = c + .5
        Line (100 + x, 475 + y)-(300 - x, 525 - y), _RGB32(100 + c, 100 + c, 200 + c), B
    Next y
Next x
Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
_PrintString (120, 495), "Pounds To Kilograms"
c = 0

'km2m
For x = 1 To 30
    For y = 1 To 30
        c = c + .5
        Line (500 + x, 100 + y)-(700 - x, 150 - y), _RGB32(100 + c, 100 + c, 200 + c), B
    Next y
Next x
Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
_PrintString (520, 120), "Kilometers To Miles"
c = 0

'm2km
For x = 1 To 30
    For y = 1 To 30
        c = c + .5
        Line (500 + x, 175 + y)-(700 - x, 225 - y), _RGB32(100 + c, 100 + c, 200 + c), B
    Next y
Next x
Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
_PrintString (520, 195), "Miles To Kilometers"
c = 0

'l2g
For x = 1 To 30
    For y = 1 To 30
        c = c + .5
        Line (500 + x, 250 + y)-(700 - x, 300 - y), _RGB32(100 + c, 100 + c, 200 + c), B
    Next y
Next x
Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
_PrintString (540, 270), "Liters To Gallons"
c = 0

'g2l
For x = 1 To 30
    For y = 1 To 30
        c = c + .5
        Line (500 + x, 325 + y)-(700 - x, 375 - y), _RGB32(100 + c, 100 + c, 200 + c), B
    Next y
Next x
Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
_PrintString (540, 345), "Gallons To Liters"
c = 0

'km/h to m/h
For x = 1 To 30
    For y = 1 To 30
        c = c + .5
        Line (500 + x, 400 + y)-(700 - x, 450 - y), _RGB32(100 + c, 100 + c, 200 + c), B
    Next y
Next x
Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
_PrintString (520, 420), "KM/Hour To Miles/Hour"
c = 0

'm/h to km/h
For x = 1 To 30
    For y = 1 To 30
        c = c + .5
        Line (500 + x, 475 + y)-(700 - x, 525 - y), _RGB32(100 + c, 100 + c, 200 + c), B
    Next y
Next x
Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
_PrintString (520, 495), "Miles/Hour To KM/Hour"
c = 0


mouseWasDown = 0

Do

    Do While _MouseInput
        xx = _MouseX
        yy = _MouseY

        If _MouseButton(1) Then
            mouseIsDown = 1
            Exit Do
        Else
            mouseIsDown = 0
        End If
    Loop

    If xx > 100 And xx < 300 And yy > 100 And yy < 150 Then
        If mouseIsDown = 1 And mouseWasDown = 0 Then
            celsius$ = _InputBox$("Celsius To Fahrenheit", "Enter Celsius Degrees")
            If Val(celsius$) = 0 And celsius$ <> "0" Then
                GoSub focus
                GoTo skip
            End If
            ct$ = LTrim$(celsius$)
            ct2$ = RTrim$(celsius$)
            If ct$ + ct2$ = "" Then
                GoSub focus
                GoTo skip
            End If
            ce = Val(celsius$)
            F = (ce * 1.8) + 32
            _MessageBox "Fahrenheit", Str$(F), ""
            GoSub focus
        End If
    End If

    If xx > 100 And xx < 300 And yy > 175 And yy < 225 Then
        If mouseIsDown = 1 And mouseWasDown = 0 Then
            Fahrenheit$ = _InputBox$("Fahrenheit To Celsus", "Enter Fahrenheit Degrees")
            If Val(Fahrenheit$) = 0 And Fahrenheit$ <> "0" Then
                GoSub focus
                GoTo skip
            End If
            ct$ = LTrim$(Fahrenheit$)
            ct2$ = RTrim$(Fahrenheit$)
            If ct$ + ct2$ = "" Then
                GoSub focus
                GoTo skip
            End If
            f2 = Val(Fahrenheit$)
            ce2 = (f2 - 32) / 1.8
            _MessageBox "Celsius", Str$(ce2), ""
            GoSub focus
        End If
    End If

    If xx > 100 And xx < 300 And yy > 250 And yy < 300 Then
        If mouseIsDown = 1 And mouseWasDown = 0 Then
            grams$ = _InputBox$("Grams To Ounces", "Enter Grams")
            If Val(grams$) = 0 And grams$ <> "0" Then
                GoSub focus
                GoTo skip
            End If
            ct$ = LTrim$(grams$)
            ct2$ = RTrim$(grams$)
            If ct$ + ct2$ = "" Then
                GoSub focus
                GoTo skip
            End If
            g = Val(grams$)
            o = 0.035274 * g
            _MessageBox "Ounces", Str$(o), ""
            GoSub focus
        End If
    End If


    If xx > 100 And xx < 300 And yy > 325 And yy < 375 Then
        If mouseIsDown = 1 And mouseWasDown = 0 Then
            ounces$ = _InputBox$("Ounces To Grams", "Enter Ounces")
            If Val(ounces$) = 0 And ounces$ <> "0" Then
                GoSub focus
                GoTo skip
            End If
            ct$ = LTrim$(ounces$)
            ct2$ = RTrim$(ounces$)
            If ct$ + ct2$ = "" Then
                GoSub focus
                GoTo skip
            End If
            o2 = Val(ounces$)
            g2 = 28.3495 * o2
            _MessageBox "Grams", Str$(g2), ""
            GoSub focus
        End If
    End If


    If xx > 100 And xx < 300 And yy > 400 And yy < 450 Then
        If mouseIsDown = 1 And mouseWasDown = 0 Then
            kg$ = _InputBox$("Kilograms To Pounds", "Enter Kilograms")
            If Val(kg$) = 0 And kg$ <> "0" Then
                GoSub focus
                GoTo skip
            End If
            ct$ = LTrim$(kg$)
            ct2$ = RTrim$(kg$)
            If ct$ + ct2$ = "" Then
                GoSub focus
                GoTo skip
            End If
            kg = Val(kg$)
            p = kg * 2.20462
            _MessageBox "Pounds", Str$(p), ""
            GoSub focus
        End If
    End If

    If xx > 100 And xx < 300 And yy > 475 And yy < 525 Then
        If mouseIsDown = 1 And mouseWasDown = 0 Then
            pounds$ = _InputBox$("Pounds To Kilograms", "Enter Pounds")
            If Val(pounds$) = 0 And pounds$ <> "0" Then
                GoSub focus
                GoTo skip
            End If
            ct$ = LTrim$(pounds$)
            ct2$ = RTrim$(pounds$)
            If ct$ + ct2$ = "" Then
                GoSub focus
                GoTo skip
            End If
            p2 = Val(pounds$)
            kg2 = p2 / 2.20462
            _MessageBox "Kilograms", Str$(kg2), ""
            GoSub focus
        End If
    End If

    If xx > 500 And xx < 700 And yy > 100 And yy < 150 Then
        If mouseIsDown = 1 And mouseWasDown = 0 Then
            km$ = _InputBox$("Kilometers To Miles", "Enter Kilometers")
            If Val(km$) = 0 And km$ <> "0" Then
                GoSub focus
                GoTo skip
            End If
            ct$ = LTrim$(km$)
            ct2$ = RTrim$(km$)
            If ct$ + ct2$ = "" Then
                GoSub focus
                GoTo skip
            End If
            km = Val(km$)
            mi = km * 0.621371
            _MessageBox "Miles", Str$(mi), ""
            GoSub focus
        End If
    End If

    If xx > 500 And xx < 700 And yy > 175 And yy < 225 Then
        If mouseIsDown = 1 And mouseWasDown = 0 Then
            miles$ = _InputBox$("Miles To Kilometers", "Enter Miles")
            If Val(miles$) = 0 And miles$ <> "0" Then
                GoSub focus
                GoTo skip
            End If
            ct$ = LTrim$(miles$)
            ct2$ = RTrim$(miles$)
            If ct$ + ct2$ = "" Then
                GoSub focus
                GoTo skip
            End If
            mi = Val(miles$)
            km = mi * 1.60934
            _MessageBox "Kilometers", Str$(km), ""
            GoSub focus
        End If
    End If

    If xx > 500 And xx < 700 And yy > 250 And yy < 300 Then
        If mouseIsDown = 1 And mouseWasDown = 0 Then
            liters$ = _InputBox$("Liters To Gallons", "Enter Liters")
            If Val(liters$) = 0 And liters$ <> "0" Then
                GoSub focus
                GoTo skip
            End If
            ct$ = LTrim$(liters$)
            ct2$ = RTrim$(liters$)
            If ct$ + ct2$ = "" Then
                GoSub focus
                GoTo skip
            End If
            l = Val(liters$)
            Ga = 0.264172 * l
            _MessageBox "Gallons", Str$(Ga), ""
            GoSub focus
        End If
    End If

    If xx > 500 And xx < 700 And yy > 325 And yy < 375 Then
        If mouseIsDown = 1 And mouseWasDown = 0 Then
            gallons$ = _InputBox$("Gallons To Liters", "Enter Gallons")
            If Val(gallons$) = 0 And gallons$ <> "0" Then
                GoSub focus
                GoTo skip
            End If
            ct$ = LTrim$(gallons$)
            ct2$ = RTrim$(gallons$)
            If ct$ + ct2$ = "" Then
                GoSub focus
                GoTo skip
            End If
            g = Val(gallons$)
            l2 = g * 3.78541
            _MessageBox "Liters", Str$(l2), ""
            GoSub focus
        End If
    End If

    If xx > 500 And xx < 700 And yy > 400 And yy < 450 Then
        If mouseIsDown = 1 And mouseWasDown = 0 Then
            kmh$ = _InputBox$("KPH To MPH", "Enter KPH")
            If Val(kmh$) = 0 And kmh$ <> "0" Then
                GoSub focus
                GoTo skip
            End If
            ct$ = LTrim$(kmh$)
            ct2$ = RTrim$(kmh$)
            If ct$ + ct2$ = "" Then
                GoSub focus
                GoTo skip
            End If
            kmh = Val(kmh$)
            mph = 0.621371 * kmh
            _MessageBox "Miles per Hour", Str$(mph), ""
            GoSub focus
        End If
    End If

    If xx > 500 And xx < 700 And yy > 475 And yy < 525 Then
        If mouseIsDown = 1 And mouseWasDown = 0 Then
            mph$ = _InputBox$("MPH to KPH", "Enter MPH")
            If Val(mph$) = 0 And mph$ <> "0" Then
                GoSub focus
                GoTo skip
            End If
            ct$ = LTrim$(mph$)
            ct2$ = RTrim$(mph$)
            If ct$ + ct2$ = "" Then
                GoSub focus
                GoTo skip
            End If
            mph = Val(mph$)
            kmh = 1.60934 * mph
            _MessageBox "Kilometers per Hour", Str$(kmh), ""
            GoSub focus
        End If
    End If

    skip:
    mouseWasDown = mouseIsDown

Loop Until InKey$ = Chr$(27)
Color _RGB32(255, 255, 255), _RGB32(0, 0, 0)
End
focus:
_Delay .25
positionX& = _ScreenX
positionY& = _ScreenY
_ScreenClick positionX& + 30, positionY& + 100
Return
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  WinAPI Mouse Demo Pete 0 183 12-20-2025, 06:40 PM
Last Post: Pete
  Numbers to Roman Numerals Converter SierraKen 15 3,349 08-14-2024, 04:56 PM
Last Post: SierraKen
Star GPT-4o - BBOX Mouse States - Experiment with a diagram to hint at creation of code. grymmjack 10 2,429 08-10-2024, 04:36 PM
Last Post: Pete
  Some MOUSE Routines TerryRitchie 2 969 06-05-2024, 06:22 AM
Last Post: TerryRitchie
  MouseyBalls, playing with balls using mouse (repel/attract) Dav 3 1,366 10-13-2023, 10:57 PM
Last Post: Dav

Forum Jump:


Users browsing this thread: 1 Guest(s)