Solved

MSHFlexGrid Question

Posted on 2000-04-11
5
142 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
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 142

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now