Solved

Syntax checking in text box

Posted on 1998-11-10
10
151 Views
Last Modified: 2010-05-18
I have a multiline text box which is used to enter ascii code for a printer language. eg.
A100,100,0,5,1,1,N,"data"

I want to provide a syntax prompt in a window like in VB. For example when you type MsgBox, it prompts you for the various parameters.
Is this possible ? How can I do it ?
0
Comment
Question by:bumpy
10 Comments
 
LVL 4

Expert Comment

by:idcanada
ID: 1444098

This isn't an easy question at all,
but I can work with you on this one as I have already started
a sample project to do such a thing.

Their are so many validations to consider,
the Backspace key, up and down arrows must scroll threw the box,
enter must select etc.

Give me you email address and we could work on it togther.




0
 
LVL 1

Expert Comment

by:MAVERICK
ID: 1444099
Ok.... firstly I would use a Rich Text box....

The easiest way to implement that is to use a Code to find the start of the line then count the number of comma's then have a second single line RTB at the top of the form with the syntax promptes.....

If You would like me to ... I could probably modify the code for  the 'RTF cursor position' routine... that'd work ok...
MAVERICK
 
0
 
LVL 1

Expert Comment

by:MAVERICK
ID: 1444100
Actually It is a fairly easy Question... if you have the code snippets available .....

BTW arn't you supposed to answer the Question ... when you submit the answer......

If you would like to ask any questions regarding my previous comments ... my ICQ is 6631387.. call me!

0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:bumpy
ID: 1444101
Maverick's idea of another single line RTB was good.
This could work. I would like to see the code for the cursor line position.

I had hoped to use a method which looks like the VB method. (It kinda looks nice). I wondered if there is some way of using the tooltips or an api function.



0
 
LVL 1

Expert Comment

by:MAVERICK
ID: 1444102
OK.... I'll find the code.....

BTW where would you like to obtain the syntax from... a *.MDB file ???

My ICQ is 6631387

Regards
Jon

0
 
LVL 12

Expert Comment

by:mark2150
ID: 1444103
I use the tool tip text property to give advice on a dynamic basis to the user. As you figure out what you want to tell them, place the text into the tool tip property.

M

0
 

Author Comment

by:bumpy
ID: 1444104
Ok Mark, I would like to use the tool tip text property, but how can I show the tool tip after one letter has been typed.
I thought the tool tip only comes up when the mouse is placed over an object.

Bumpy.
0
 

Expert Comment

by:bsvarma
ID: 1444105
if u want to use it using a word application from vb then i can solve this probelm . do mail to me if required
0
 
LVL 1

Expert Comment

by:MAVERICK
ID: 1444106
You still want that RTF position APP?>


0
 
LVL 3

Accepted Solution

by:
jbil earned 200 total points
ID: 1444107
'Not complete but could be starting point

'2 textbox's text1 and text2
'put smaller text2 inside larger text2
'set text2 zorder to 1
'set text2 background color like vb's prompt
'set scalemode to pixles
'run and type "msgbox" and hit space key
Private Declare Function GetCaretPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
     X As Long
     Y As Long
End Type

Private Sub Form_Load()
Me.Show
Text1.SetFocus

End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Dim caret As POINTAPI
Dim mystring As String
Dim mypos As Integer

GetCaretPos caret
'Debug.Print KeyCode
Select Case KeyCode

Case 32
mystring = "msgbox" 'could be array of choices to loop thru and compare
mypos = InStr(1, Text1.Text, mystring, vbTextCompare)
'need better way to check word just typed
If KeyCode = 32 And mypos > 0 Then
Text2.Left = Text1.Left + caret.X + Text1.Font.Size
Text2.Top = (Text1.Top + caret.Y + (Text1.Font.Size * 2))
Text2.Text = "MsgBox(prompt[, buttons] [, title] [, helpfile, context])"
'or sumtin else depending on mystring array
Text2.ZOrder (0)
End If
Case 40
Text2.ZOrder (1)
Case 38
Text2.ZOrder (1)
Case 13
Text2.ZOrder (1)
Case Else
KeyCode = KeyCode
'Text2.ZOrder (1)
End Select

End Sub


0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

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…
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.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

816 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

11 Experts available now in Live!

Get 1:1 Help Now