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
Solved

MSHFlexGrid Question

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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…

808 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