?
Solved

MSHFlexGrid Question

Posted on 2000-04-11
5
Medium Priority
?
148 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 150 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

752 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