messageboxbuttons

时间:2024-05-17 16:16:49编辑:coo君

vb6.0中MessageBox怎么用

很简单
比如:
Private Sub Command1_Click()
If Text1.Text = "20100344" Then
MsgBox ("登陆成功!")
Shell "C:\Documents and Settings\Administrator\桌面\登录系统组件\bin\bg1.exe"
End
Else
MsgBox ("您的输入有误,请重新输入!")
End If
End Sub
这是输入密码是的 MessageBox 。
还可以这样:
Private Sub Command1_Click()
MsgBox "正在退出,请稍候!"
End
End Sub
这是退出vb软件时的 MessageBox 。


关于vb程序下messagebox的使用

MsgBox 函数,在对话框中显示消息,等待用户单击按钮,并返回一个 Integer 告诉用户单击哪一个按钮。语法设置值MsgBox 函数示例本示例使用 MsgBox 函数,在具有“是”及“否”按钮的对话框中显示一条严重错误信息。示例中的缺省按钮为“否”,MsgBox 函数的返回值视用户按哪一个钮而定。本示例假设 DEMO.HLP 为一帮助文件,其中有一个内容代码为 1000。Private Sub Form_Click() Dim Msg, Style, Title, Help, Ctxt, Response, MyString Msg = "Do you want to continue ?" ' 定义信息。 Style = vbYesNo + vbCritical + vbDefaultButton2 ' 定义按钮。 Title = "MsgBox Demonstration" ' 定义标题。 Help = "DEMO.HLP" ' 定义帮助文件。 Ctxt = 1000 ' 定义标题 ' 上下文。 ' 显示信息。 Response = MsgBox(Msg, Style, Title, Help, Ctxt) If Response = vbYes Then ' 用户按下“是”。 MyString = "Yes" ' 完成某操作。 Else ' 用户按下“否”。 MyString = "No" ' 完成某操作。 End IfEnd Sub将上述代码中Msg = "Do you want to continue ?" 改为:Msg = "Hello world!"就可以满足要求。

c# 怎样使用messagebox 显示是、否 按钮,然后选择的按钮的事件在哪写代码?

DialogResult dr= MessageBox.Show("内容?","对话框标题", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr == DialogResult.OK)
{
//点确定的代码
}
else
{ //点取消的代码 }


C#如何自动关闭messagebox

对话框是模式窗口,显示后“焦点”在默认的按键上。显示对话框,同时启动定时器,延时一段时间后,利用代码向对话框发送按键Enter,模拟用户按下Enter键,达到自动关闭对话框的目的。实现方法如下:(1)在Visual Studio中新建一个“Windows 窗体应用程序”(2)在Form1上布置一个Button和一个Timer(3)窗体代码Form1.csusing System;using System.Windows.Forms;namespace WindowsFormsApplication1{ public partial class Form1 : Form { public Form1() { InitializeComponent(); button1.Text = "显示对话框"; } private void button1_Click(object sender, EventArgs e) { //启动定时器 timer1.Interval = 3000; timer1.Start(); // 显示对话框 MessageBox.Show("3秒钟,这个对话框后自动关闭!", "自动关闭的对话框", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information); } private void timer1_Tick(object sender, EventArgs e) { // 停止定时器 timer1.Stop(); // 向对话框发送按键 Enter SendKeys.Send("ENTER"); } }}(4)运行效果3秒以后……对话框关闭

C# MessageBox.Show()怎么设置3秒后 自动关闭?

写好了,以下是截图和部分源码,完整的源码在附件中:1.指定要弹出的消息以及定时的时间(单位秒)2.弹出后,对话框上的确定按钮上会动态倒计时,当时间为0时自动关闭,也可以通过点击确定按钮关闭核心代码: public partial class TimingMessageBox : Form { // 自动关闭的时间限制,如3为3秒后自动关闭 private int second; // 计数器,用以判断当前窗口弹出后持续的时间 private int counter; // 构造函数 public TimingMessageBox(string message, int second) { InitializeComponent(); // 显示消息 this.labelMessage.Text = message; // 获得时间限制 this.second = second; // 初始化计数器 this.counter = 0; // 初始化按钮的文本 this.buttonOK.Text = string.Format("确定({0})", this.second - this.counter); // 激活并启动timer,设置timer的触发间隔为1000毫秒(1秒) this.timer1.Enabled = true; this.timer1.Interval = 1000; this.timer1.Start(); } private void timer1_Tick(object sender, EventArgs e) { // 如果没有到达指定的时间限制 if (this.counter <= this.second) { // 刷新按钮的文本 this.buttonOK.Text = string.Format("确定({0})", this.second - this.counter); this.Refresh(); // 计数器自增 this.counter++; } // 如果到达时间限制 else { // 关闭timer this.timer1.Enabled = false; this.timer1.Stop(); // 关闭对话框 this.Close(); } } private void buttonOK_Click(object sender, EventArgs e) { // 单击确定按钮,关闭对话框 this.Close(); } }然后在主窗体中调用:public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void buttonShowMessageBox_Click(object sender, EventArgs e) { string message = this.textBoxMessage.Text.Trim(); int second = Convert.ToInt32(this.textBoxSecond.Text.Trim()); TimingMessageBox messageBox=new TimingMessageBox(message,second); messageBox.ShowDialog(); } }

C#窗体中如何让messagebox上显示自定义按钮

DialogResult dr= MessageBox.Show("内容?","对话框标题", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr == DialogResult.OK)
{
//点确定的代码
}
else
{ //点取消的代码 }


C#MessageBox弹出的确认对话框怎么写事件,比如点击确定按钮 ,要执行某个操作,怎么写事件

DialogResult dr= MessageBox.Show("内容?","对话框标题", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr == DialogResult.OK)
{
//点确定的代码
}
else
{ //点取消的代码 }


点击C#的messagebox.show()中的确定按钮怎么链接到另外的页面。

可以通过一个变量来获取用户选择messagebox的值
DialogResult dr = MessageBox.Show();
通常来说,messagebox要么就是一个OK键,要么就还有一个cancel键

这些值已经在dr里面了

至于楼主要实现的某个键实现某个功能
就可以通过判断dr的值来执行

例如用户点击OK以后,跳转到百度首页
那么
if (dr==DialogResult.OK)
{
Process.Start("http://www.baidu.com");
}
就可以了

有问题可以百度HI
不在线可以留言


C# Messagebox 确定 取消 按钮的方法怎么写?

DialogResult result=MessageBox.Show("内容", "标题", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);if(result==DialogResult.OK){//确定按钮的方法}else{//取消按钮的方法}扩展资料:MessageBox的常见用法一、按钮组合常量MB_OK = $00000000;一个确定按钮MB_OKCANCEL = $00000001;一个确定按钮,一个取消按钮MB_ABORTRETRYIGNORE = $00000002;一个异常终止按钮,一个重试按钮,一个忽略按钮MB_YESNOCANCEL = $00000003;一个是按钮,一个否按钮,一个取消按钮MB_YESNO = $00000004;一个是按钮,一个否按钮MB_RETRYCANCEL = $00000005;一个重试按钮,一个取消按钮二、函数原型function MessageBox(hWnd: HWND; Text, Caption: PChar; Type: Word): Integer;hWnd:对话框父窗口句柄,对话框显示在Delphi窗体内,可使用窗体的Handle属性,否则可用0,使其直接作为桌面窗口的子窗口。Text:欲显示的信息字符串。Caption:对话框标题字符串。Type:对话框类型常量。该函数的返回值为整数,用于对话框按钮的识别。

上一篇:机械舞入门教学视频

下一篇:韩庚微博新浪