Just out of curiousity…
When making a MsgBox, I usually construct the strings all on the same line. I’ve noticed that many people declare variables even for the elements that don’t change. For example, the two Subs below perform the same task. I’d tend to use the latter because I find it easier to write and read. Is there ANY advantage to the former method?
Sub PieEating1() Dim strTitle As String Dim strMessage1 As String Dim strMessage2 As String Dim strMessage As String Dim intPieCount As Integer Dim intDialog As Integer strTitle = "How many pies have you eaten?" strMessage1 = "You have eaten " strMessage2 = " pies." intPieCount = 3 strMessage = strMessage1 & CStr(intPieCount) & strMessage2 intDialog = vbExclamation MsgBox strMessage, intDialog, strTitle End Sub
Sub PieEating2() Dim intPieCount As Integer intPieCount = 3 MsgBox "You have eaten " & CStr(intPieCount) & " pies.", _ vbExclamation, _ "How many pies have you eaten?" End Sub
Hope someone can shed some light on this. Thanks!
Mark