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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have two questions: 1.[/b

Status
Not open for further replies.

robman70

Technical User
Aug 6, 2002
90
0
0

I have two questions:

1. I use to use a program that when you right clicked on the toolbar, a menu displayed with a 'always on top' option, which made that window always on top of anything else open, does anyone have any idea how i could do this with visual basic?

2. I have a text area, txtPhone, when i put a phone number in it (7135551212) i would like to be able to click a button, cmdFormat, and it make print back to txtPhone.Text the same number just in 713 555-1212 format, then click cmdUnFormat and it put it back to 7135551212

ive been trying, but cant seem to figure either out, if anyone can help me with either of these, i would greatly appreciate it

thanks
 
An easy way would be to copy the txtPhone.text to a hidden maskedit control with the required mask set:
Maskedbox1.mask = "### ###-####"

You could copy on the txtPhone_Change event

Then dispay your text with:
Private Sub CmdFormat_Click()
MaskEdBox1.PromptInclude = True
MsgBox MaskEdBox1.Text
End Sub
Private Sub CmdUnFormat_Click()
MaskEdBox1.PromptInclude = False
MsgBox MaskEdBox1.Text
End Sub
Let me know if this helps
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
To keep you window on top use the following code. I got this from DSI on this site.

Code:
Assuming you are talking about a form:
You can use the SetWindowPos API function.

'To Force Form On Top
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
'For SetWindowPos
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2

    Dim i As Long
    'Force Form On Top
    i = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)
    'Remove Forced Setting
    i = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)

The hardest questions always have the easiest answers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top