Solved

MSHFlexGrid Question

Posted on 2000-04-11
5
146 Views
Last Modified: 2010-05-02
Is there anyway to tell if the user has typed more then the space allows? For example if the column width is only big enough to hold 4 characters and the user inputs 6, is there anyway to know.

Actually, I just really need the algorithm to determine how many letters were typed, if you can help, that would be great.
0
Comment
Question by:the_chosen_one
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 14

Accepted Solution

by:
mcrider earned 50 total points
ID: 2704001
Set your Form's font attributes to be the same as the grid cell (name, size, bold, etc...) then use:

Dim X As Long
X=Me.TextWidth(grid.text)

X Will contain the number of twips the text takes up... You can then compare it against the column width...


Cheers!®©
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 2704066
mcrider, you might revise you comment, i think the_chosen_one only wants to know how many caracters the user has typed, to be compared with the number of bytes he can store in the given database column...
I don't have HFlexgrid here, so i can't check this up

Cheers
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2704840
how is the user inputting values that will be in the grid?
0
 
LVL 1

Expert Comment

by:Chrynoble
ID: 2708507
AzraSound is on the right track. You can't enter data directly into a flex grid.
There are some ways to make it look like you are though.

On that note, what ever control you are using to let them enter the data add the following to a keydown event.

    If KeyCode = 16 Then Exit Sub ' This is the shift key. You may need to trap other similar keys
    If TextBox1.Text = "" And KeyCode = 8 Then
        TheText = ""
    ElseIf KeyCode = 8 Then
        TheText = Left(TextBox1.Text, Len(TextBox1.Text) - 1)
    Else
        TheText = TextBox1.Text & Chr(KeyCode)
    End If
    NumOfChars = Len(TheText)
    Label1.Caption = "The string is : " & NumOfChars & " long."

if you just want to test to see if the text will fit then mcriders fix might be best.
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2777236
Thanks for the points! Glad I could help!


Cheers!®©
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question