Results 1 to 40 of 1650

Thread: VBFlexGrid Control (Replacement of the MSFlexGrid control)

Threaded View

  1. #10
    Addicted Member
    Join Date
    May 2022
    Posts
    144

    Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)

    Hi again.

    Where an how is the best way to validate an input?

    I mean, i want a cell / col that only allows numbers.

    following your example, i used:

    Code:
    Private Sub Gr1_EditSetupStyle(dwStyle As Long, dwExStyle As Long)
    
    Const ES_NUMBER As Long = &H2000
       Select Case Gr1.EditCol
          Case 3      'solo numeros
            dwStyle = dwStyle Or ES_NUMBER
        End Select
    
    End Sub

    But with this, i can't enter decimals ('.' or ',')

    Maybe I must check all the keypress at cell ?, is there another Constant that allows numbers and decimals ?

    Thanks!



    Edit:

    Solved this way (I accept better ways to do it xD):

    Code:
    Private Sub Gr1_EditKeyPress(KeyChar As Integer)
    
    If InStr("all the keys of the columns i want to check", Gr1.ColKey(Gr1.EditCol)) >= 1 Then
        If Not (KeyChar >= vbKeyA And KeyChar <= vbKeyZ) And Not (KeyChar >= 97 And KeyChar <= 122) Then    
            Else
                KeyChar = 0
        End If
    End If
    
    End Sub
    Last edited by Calcu; Jul 9th, 2023 at 03:25 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width