Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do you suppress the @ section separator in the MsgBox function?

2 views
Skip to first unread message

Douglas J. Taylor Jr.

unread,
Jan 25, 1999, 3:00:00 AM1/25/99
to
Dim strChr As String

strChr = vbCrLf & vbCrLf

MsgBox "FirstLine" & strChr & _
"SecondLine" & strChr & _
"som...@somewhere.com"

The only problem is the first line won't be bold text.
--
Doug
Reply to is anti-spammed remove the "z" from email
or click here: do...@email.msn.com

Nick wrote in message <36acf...@news.actrix.gen.nz>...
>I am trying to display email addresses in a MsgBox, but the "@" character
>triggers the function to format the message into sections. The VBA Help
>doesn't say anything about avoiding this behaviour.
>
>Has anyone found a way to change the separator character or stop MsgBox
>formatting into sections ?
>
>Nick Stewart
>
>

Nick

unread,
Jan 26, 1999, 3:00:00 AM1/26/99
to

Ken Getz

unread,
Jan 26, 1999, 3:00:00 AM1/26/99
to
In article <36acf...@news.actrix.gen.nz>, ni...@coastal.co.nz says...
No, there's no way to convince Msgbox not to do this, as far as I know. I
wrote this up for Advisor's mag a while back:

This is what I sent in:

If you’re an Access developer, you may have noticed that the MsgBox
function in Access handles things differently than the standard MsgBox
function in other applications. First of all, it uses a different font
than the standard Windows font. In addition, it plays a neat trick with
“@” signs in the text. If it finds two “@” signs in your prompt, it takes
the portion before the first “@”, and makes it bold. Then, two lines
lower, it displays the text between the two “@” signs, and finally, two
lines lower, displays the part after the second “@” sign. (If you have
more than two “@” signs, Access disregards everything including and after
the third “@” sign). This makes it easy to indicate a problem (in bold)
and then offer two paragraphs of explanation, neatly broken out. It would
be nice if this was documented. If you want to test this out, try this in
the Access Debug window:

MsgBox "Hello@There@Mike!"

The problem is that you may want to display “@” signs as part of your
message box. For example, what if you wanted to display the string
“Contact me at ke...@mcwtech.com or 76137...@compuserve.com” in a
message box? Not possible, at least by any means I’ve found, in Access
97. You could create your own form that looks like a message box, and
handle all the details yourself. That’s a lot of work. Another
alternative is to use the built-in Windows API MessageBox function, which
does just about the same thing as the Access MsgBox function (it uses the
same constants and return values), but doesn’t exhibit this strange
behavior.

To test this out, I wrote a little wrapper around the API function,
MsgBoxAPI, and compared it with the built-in MsgBox, as shown here:

Private Declare Function MessageBox _
Lib "user32" Alias "MessageBoxA" _
(ByVal hwnd As Long, ByVal lpText As String, _
ByVal lpCaption As String, ByVal wType As Long) As Long

Function MsgBoxAPI( _
Prompt As String, Optional Buttons As Long = vbOKOnly, _
Optional Title = "Microsoft Access") As Long
MsgBoxAPI = MessageBox(Application.hWndAccessApp, Prompt, Title,
Buttons)
End Function

Sub TestMsgBox()
Debug.Print MsgBox("Use either x...@y.com or 76137...@compuserve.com",
vbYesNo)
Debug.Print MsgBoxAPI("Use either x&y.com or
76137...@compuserve.com", _
vbYesNo)
End Sub

You’ll see, if you try them both out, that the API version doesn’t mangle
your text. (You'll need to rewrap some of the code to get it to work...)

-- Ken

-- Ken

bilt

unread,
Feb 20, 1999, 3:00:00 AM2/20/99
to

I havent tried this but if u want to return the @ within a msgbox try using
it's character set code instead. Unfortunately i dont no its no. but its easy
to find using help/index and then type chr in the find box. Replace 'No.' with
the correct character number in the following example
Msbox "EmailMe" & chr('No.') & "Mydomain.com"

Hope it works
cheers
Bilt

Ken Getz wrote:

> In article <36acf...@news.actrix.gen.nz>, ni...@coastal.co.nz says...
> > I am trying to display email addresses in a MsgBox, but the "@" character
> > triggers the function to format the message into sections. The VBA Help
> > doesn't say anything about avoiding this behaviour.

> No, there's no way to convince Msgbox not to do this, as far as I know. I

0 new messages