如何控制MSHFLEXGRID的第二列和第三列的输入格式?只能输入数字,急呀。
我想在第二列和第三列里只能输入数字型,其它不能输入。

解决方案 »

  1.   


    dim i
    for i=1 to fg.rows-1
        if not isnumeric(fg.textmatrix(i, 2)) or _
        not isnumeric(fg.textmatrix(i, 3)) then
            msgbox"2,3列只能输入数字"
            exit sub
        end if
    next i
      

  2.   

    Private Sub MSHFlexGrid1_LeaveCell()
        With MSHFlexGrid1
            If .Col = 2 Or .Col = 3 Then
                 If Not IsNumeric(.TextMatrix(.Row, .Col)) Then
                     MsgBox "输入必须为数字"
                  End If
            End If
        End With
        
    End Sub
      

  3.   

    private sub mshflexgrid1_change()
      if mshflexgrid1.col=2 or mshflexgrid1.col=3 then
         if not isnumeric(.text) then
            msgbox "2,3列必须输入数字"
         endif  
      endif
    end sub