-
January 31st, 2009, 06:39 AM
#1
Easy MsgBox!
I use MsgBox a lot in development to make sure that variables have the proper values before proceeding further.
I wrote the following Sub to display up to 4 variables, and take care of bothersome keystrokes and converions!
Please review, use, and suggest some improvements!
' Easy MsgBox
Sub mb(String1 As Variant, Optional String2 As Variant, Optional String3 As Variant, Optional String4 As Variant)
Dim txt$
' String1
If IsMissing(String1) Then String1 = ""
If IsNumeric(String1) Then String1 = Str$(String1)
' String2
If IsMissing(String2) Then String2 = ""
If IsNumeric(String2) Then String2 = Str$(String2)
If String2 <> "" Then String2 = " " + String2
' String3
If IsMissing(String3) Then String3 = ""
If IsNumeric(String3) Then String3 = Str$(String3)
If String3 <> "" Then String3 = " " + String3
' String4
If IsMissing(String4) Then String4 = ""
If IsNumeric(String4) Then String4 = Str$(String4)
If String4 <> "" Then String4 = " " + String4
' display message
txt$ = Trim$(String1 & String2 & String3 & String4)
MsgBox (txt$)
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|