numeric input

Discussion in 'AutoCAD' started by cesi2d, Sep 28, 2004.

  1. cesi2d

    cesi2d Guest

    hello

    In vba forms , we are controling the numeric input with the keypress
    evenment.
    The control is good for decimal input .
    How can we do the same , but in inches input (decimal and/or fractionnal) ?

    If everyone has a dvb project , or a module , or an ocx , or explainations
    , please help us

    --
    Cesi2d
    Luc Vallot
    Chemin du Bassard
    38121 Chonas l ' amballan
    France


    Tel: 04 74 58 95 68
     
    cesi2d, Sep 28, 2004
    #1
  2. cesi2d

    SpeedCAD Guest

    Hi...

    Hmmm, you may convert of inches to decimal and next do the control... Finaly again do the convert of decimal to inches.

    Just is a idea...

    Un saludo de SpeedCAD... :D
    CHILE
    FORO: http://www.hispacad.com/foro
     
    SpeedCAD, Sep 29, 2004
    #2
  3. cesi2d

    AKS Guest

    Luc,

    In my opinion the best
    way from both a user and programming viewpoint is to
    separate the different unit types into their own entry boxes.
    That way the user does not have to bother with entering in
    a unit type. He would just know that one entry box was for
    the major unit and the next entry box was for the minor unit.
    You as programmer would not need to develop the entry
    parsing routine for all the variations of unit type ( ' or " or mm
    or MM or M etc.) It helps to provide instant feedback to the
    user as to what his entries equate to. This would be simply
    a Label in the userform that represents the entry inputs in a formatted form. So for example a 24.5 in the foot entry and a 27 in the inches entry would feedback as " 26' - 9" ". In
    otherwords it is much easier to feedback a single style
    formatted result than to parse a formatted entry that might
    be entered many different ways.

    Allowing fractions to uccur in the entry complicates the task.
    Here is one crude method that was suited a specific task. It may not be suitable for you.

    tbTH is a Textbox, lbPTSis the feedback Label

    Private Sub tbTH_Change()
    Me.lbPTS = Format(Parse2VAl(Me.tbTH), "#.00000")
    End Sub

    Function Parse2VAl(str As String) As Variant
    Dim x As Integer
    Dim nom As Double
    Dim dem As Double
    On Error GoTo limbo
    If IsNumeric(str) Then
    Parse2VAl = str
    Else
    x = InStr(1, str, "/")
    If x > 0 Then
    nom = Val(Left(str, x - 1))
    End If
    dem = Val(Right(str, Len(str) - x))
    Parse2VAl = nom / dem
    End If
    Exit Function
    limbo:
    On Error GoTo 0
    Parse2VAl = "???"
    End Function

    With much respect for your bilinguality,
    AKS
     
    AKS, Sep 29, 2004
    #3
  4. Luc,
    Look up the DistanceToReal and RealToString methods of the Utility object.

    HTH,
    James
     
    James Belshan, Sep 29, 2004
    #4
  5. cesi2d

    cesi2d Guest

    The usage of fractionnal part is a customer specification
    In europa , the input unit is millimeters all the times, but come a special
    case !.

    The problem of parsing the input , is the need of :
    have different forms depending of the unit or,
    a complex form gestion to parse or not depending of the unit.

    Parsing need 4 controls (foot + inche + numerator + fractionnal unit)

    The problem using the DistanceToReal and RealToString , is the control of
    the input
    each time the user press a key , (for exemple , if the user press the "A"
    key , refuse it , but if he press the ' key , accep it only
    then the unit is inches) , this is the best way in an user point of vue (It
    is my opinion) than controling after the input .

    Thanks for all your explanations


    form. So for example a 24.5 in the foot entry and a 27 in the inches entry
    would feedback as " 26' - 9" ". In
     
    cesi2d, Sep 30, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.