Mehrzeilige MsgBox mit Hilfe der Access-Eval-Funktion

Eval
Mit Hilfe der nur in Access vorkommenden Eval-Funktion lassen sich in VB nicht nur mathematische Berechnungen
durchführen, sondern auch Nachrichten in Message-Boxen mehrzeilig darstellen:
Private Sub cmdHelp_Click()
  Call Dreizeilige_MsgBox("Achtung!@Fehlerhafte Anwendung!@Bitte informieren Sie Ihren Support!     ", _
   vbOKOnly & vbExclamation, "Hinweis...")
End Sub
Function Dreizeilige_MsgBox(Prompt As String, _
 Optional Buttons As VbMsgBoxStyle = vbOKOnly, _
 Optional Title As String = vbNullString, _
 Optional HelpFile As Variant, _
 Optional Context As Variant) As VbMsgBoxResult
 
 If IsMissing(HelpFile) Or IsMissing(Context) Then
   Dreizeilige_MsgBox = Eval("MsgBox(""" & Prompt & """, " & _
    Buttons & ", """ & Title & """)")
 Else
   Dreizeilige_MsgBox = Eval("MsgBox(""" & Prompt & """, " & _
    Buttons & ", """ & Title & """, """ & HelpFile & """, " & Context & ")")
 End If
End Function
Dies funktioniert in VB oder VBA natürlich nur, wenn man einen entsprechenden Verweis auf die installierte
Access-Library im Projekt einträgt. So lassen sich Nachrichten mit maximal drei Zeilen darstellen.



 Ranking-Hits zurück Sitemap
Designed by www.wbrnet.info