Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Allowing user to create or change input mask 4

Status
Not open for further replies.

prettyangel

Programmer
Sep 2, 2005
38
NG
I'm a novice with VB6.

I want users to be able to define their own input mask and store it in a table.
After which they can then input into another table based on the predefined input mask.

If the input format is not the same as predefined input mask it should prompt users.
 
Your post gives rise to several questions:

1. How will you resolve the input mask the user defines?
2. What sort of table?
3. How do you intend the user to input values?

Those are good ones to start with.

Bob
 
Thanks for your response BobRodes.

User needs to be able to dynamically define format for data,
The format could be numeric,alphanumeric,placeholders e.t.c.
N - Is for numeric
A - Is for alphabets
- - Is for placeholders

meaning to make users enter numbers only, then the manager will enter "NNNNNNN" for instance into a textbox [txtMask].
for alphabets only "AAAAAAA", for alphanumeric "AANNAN" e.t.c

What the manager enters will then be stored in a table [tbMask].

Subsequently, when user wants to enter data into table
[tbAcct]
and suppose the user enters "113r556" into a textbox [txtAcct]
, a procedure should be called that will compare what is in [txtAcct] with what is in [tbMask] if the formatas are the same then "113r556" will be saved into [tbAcct]

I hope these shed more light.

Thank you once again for your response.
 
Why not use the standard MaskEdBox control found in MSMASK32.OCX using the Mask property to control input. Set the Mask property from your database

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Thanks for your response johnwm.

I'm not sure a MaskEdBox control will help me accomplish the task. Reason; Users of the software want to be able to define their own format and/or change it at will and then force sub users to conform to the new format that is why I didn't think of setting the Mask property from my database.

What do you think I can do? Please........

 
That's what the Mask property is for! Read the Help file for more details

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Thanks for your response johnwm.

I'm sorry but I don't seem to understand what you are saying.

Are you saying I should use the MaskEdit control to receive acctNo for instance, if yes that is understandable.

But the software controllers would like to be able to change format of acctNo at will like I earlier said, does this mean they can only do that from backend (MSSQL Server 7.0)?

This is my major bottleneck.
 
You can set the MaskEdBox control Mask property in code:
Code:
strMask = "(###)-AAA"
MaskEdBox1.Mask = strMask
You can get that string from anywhere - from a database, from the registry, from a textfile and change it on the fly as you need. If the above code was in the Form_Activate event, just precede it with whatever code you have to query your db


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Thank you johnwm.
I tried your suggestion and it worked, what I did was to use the standard Textbox control to receive input mask from Software controller on form1 and then opened a recordset rsMask to retrieve the stored format and then set MaskEdit controls mask property to this.

I'm really grateful.

My second problem is that I don't want users to be able to open form2 when form1 is open what code do I use for this?
and I also want user to receive message about why they can't type in a value. MaskEdit control doesn't notify it just beeps.
 
There must be a button, menu item, or something somewhere that causes form2 to open. In that code, you can check to see what forms are currently open.

There is a hidden forms collection within VB (sadly missing from vb.net).

The code would look something like this...

Code:
Dim oForm As Form

For Each oForm In Forms
    If oForm.Name = "Form1" Then
        Call MsgBox("You cannot open the data entry form while the configuration form is open.", vbInformation, "Data Entry Error")
        Exit Sub
    End If
Next

Form2.Show



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Thanks gmmastros for your response.

The code solves my problem.
Please any idea on how to notify user about why the maskedEdit control doesn't take in some certain values.

I tried this, but the msgbox becomes recursive and i'm unable to come out of the loop.

Private Sub maskedit_ValidationError(InvalidText As String, StartPosition As Integer)
MsgBox "Enter valid data"
End Sub


Any suggestions?
 
Why not send the Mask property to your MsgBox (with a brief example)

MsgBox "Your input should be " & MaskEdBox1.Mask & " where # is any numeric digit and A is any alphabetic character"

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Thanks for your response johnwm.


In what event procedure did you say I should put this?
Because putting it in the maskedit_ValidationError event will lead to an infinite loop.

What I'm trying to say is that
ordinarily when an msgbox is called, once the user acknowledges the information therein by clicking OK, the user should be taken back to the form to rectify the error but this does not happen.
 
PrettyAngel

I just duplicated your problem on my computer. For some reason (unknown to me), the message box appears to be stuck in an infinite loop.

Personally, I hate it when I am bombarded with message boxes. Obviously, they have their uses, but I'd hate to have a message box pop up every time I hit a bad key. I have another suggestion that may help.

Next to the Masked Edit Box, place a label control. Set the caption of the label control to an empty string so that you see no text on the control. Set the ForeColor to vbRed. Then, use this code.

Code:
Private Sub MaskEdBox1_Change()
    
    Label1.Caption = ""
End Sub

Private Sub MaskEdBox1_ValidationError(InvalidText As String, StartPosition As Integer)
        
    Label1.Caption = "Validation Error"
    
End Sub

It appears as though the change event is only fired if a valid key is pressed, and the ValidationError event is fired when an invalid key is pressed. So, basically, you will be displaying the error in a label control on the screen instead of a message box. I suspect your users will appreciate the label method instead of the message box method. Obviously, you know your users better than I do, and this is only a suggestion. Hope it helps.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Thanks for your response gmmastros.
I just love it, it's simple and it solves my problem.
Once again thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top