Solved

MSHFlexGrid Question

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

718 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