十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
有点复杂,如果是Excel,有Application.DisplayAlerts=False'这是Excel阻止警告
成都创新互联公司10多年成都企业网站建设服务;为您提供网站建设,网站制作,网页设计及高端网站定制服务,成都企业网站建设及推广,对玻璃隔断等多个领域拥有丰富的网站制作经验的网站建设公司。
我粗看了下MediaPlayer没有提供类似的接口,试着用消息捕获的方法看看
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) '消息捕获
If m.Msg = H999 Then '这里的值要你自己去测试出来(就是弹出对话框时的值)
SendKeys.Send("{ENTER}") '发送回车键
End If
MyBase.WndProc(m)
End Sub
Private Sub Command1_Click()
MsgBox "黄色感叹号 确定", vbExclamation, "系统提示"
End Sub
Private Sub Command2_Click()
MsgBox "绿色问号 确定!", vbQuestion, "系统提示"
End Sub
Private Sub Command3_Click()
MsgBox "绿色 i 确定", vbInformation, "系统提示"
End Sub
Private Sub Command4_Click()
MsgBox "终止 重试 忽略", vbAbortRetryIgnore, "系统提示"
End Sub
Private Sub Command5_Click()
MsgBox "是 否 取消", vbYesNoCancel, "系统提示"
End Sub
Private Sub Command6_Click()
MsgBox "确定", vbOKOnly, "系统提示"
End Sub
Private Sub Command7_Click()
MsgBox "大把 × 确定", vbCritical, "系统提示"
End Sub
Private Sub Command8_Click()
MsgBox "确定 取消", vbOKCancel, "系统提示"
End Sub
Private Sub Command9_Click()
MsgBox "确定 帮助", vbMsgBoxHelpButton, "系统提示"
End Sub
Private Sub Command10_Click()
MsgBox "重试 取消", vbRetryCancel, "系统提示"
End Sub
Private Sub Command11_Click()
MsgBox "是 否", vbYesNo, "系统提示"
End Sub
Private Function getAccessConnection() As OleDbConnection
'整体思路应该是:连接数据库-运用适配器运行查询词句-将查询结果填充到数据集-以数据集为数据源,在DataGrid中显示。
Dim dbConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=|DataDirectory|\Resources\mag.mdb;Persist Security Info=true"
'连接字符串,Provider,连接引擎,可以死记,OLEDB就用这处,Data Source,设置数据库的位置。
Dim dbConnection As OleDbConnection = New OleDbConnection(dbConnectionString)
Try
dbConnection.Open()
Catch Ex As Exception
’MsgBox(Err.Description)
End Try
Return dbConnection
End Function
private Sub fillDataGridView()
Dim sqlStr As String = "select * from Table"
Dim DataAdapter As New OleDbDataAdapter
Dim dataSet As New DataSet
Dim DataGridView As New DataGridView
Dim dbConnection As OleDbConnection = getAccessConnection()
If dbConnection.State.ToString = "Closed" Then
MsgBox(Chr(13) " access 数据库连接失败 " Chr(13), , "警告")
Exit Sub
End If
DataAdapter.SelectCommand = New OleDbCommand(sqlStr,dbConnection)
'用数据适配器进行查询
Try
DataAdapter.Fill(dataSet,"Table") '将查询结果填充到数据集Dataset,有点像VB中的记录集recordset
DataGridView.DataSource = dataSet.Tables("Table").DefaultView '将数据集的内容在表格中显示出来
Catch Ex As Exception
MsgBox(Err.Description)
Finally
dataSet.Dispose
DataAdapter.Dispose
dbConnection.Close
dbConnection.Dispose
End Try
End Sub
Private Sub TextBox1_KeyPress1(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = "A" And e.KeyChar = "Z" Or e.KeyChar = "a" And e.KeyChar = "z" Then
e.Handled = False
Else
MessageBox.Show ("只能输入字母!")
e.Handled = True
Exit Sub
End If
End Sub