1、按钮类型(常用)
(1)MsgBoxStyle.YesNo (是/否)
(2)MsgBoxStyle.OkCancel (确定/取消)
例:
MsgBox("你好!", MsgBoxStyle.YesNo, "提示")
MsgBox("你好!", MsgBoxStyle.OkCancel, "提示")
2、按钮图标(常用)
(1)MsgBoxStyle.Exclamation (警告图标)
(2)MsgBoxStyle.Information (信息图标)
(3)MsgBoxStyle.Question (询问图标)
例:
MsgBox("警告图标", MsgBoxStyle.Exclamation, "警告")
MsgBox("信息图标", MsgBoxStyle.Information, "信息消息")
MsgBox("询问图标", MsgBoxStyle.Question, "询问")
3、按钮与图标合起来用
MsgBox("确定要退出程序吗?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "提示")
4、MsgBox 返回值 (常用)
(1)MsgBoxResult.Yes (是)
(2)MsgBoxResult.No (否)
(3)MsgBoxResult.Ok (确定)
(4)MsgBoxResult.Cancel (取消)
例:
Dim 返回值 As String
返回值 = MsgBox("确定要退出程序吗?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "提示")
If 返回值 = MsgBoxResult.Yes Then
End
End If
If 返回值 = MsgBoxResult.No Then
MsgBox("你按了否")
End If