vb操作sql数据库的典型例子
本程序有一菜单开始,里面有查询,删除,修改,添加,程序不一一列出,只写出基本的过程,连接数据库采用标准模块:
'Public publicstr As String
Public conn As ADODB.Connection
Public rs As ADODB.Recordset
Public Sub main() '数据库连接共享函数
Set conn = New ADODB.Connection
conn.Open "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=plgl;Initial Catalog=plgl"
'publicstr = "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=plgl;Initial Catalog=plgl" '共享连接字符串
main_pfm.Show
End Sub
添加程序:
Set rs = New ADODB.Recordset
If Trim(Text1(0).Text) = "" Then
smeg = "配方号不能为空!!!"
MsgBox smeg, vbOKCancel + vbExclamation, "警告"
Text1(0).SetFocus
Else
If Not IsNumeric(Text1(0).Text) Then
smeg = "A添加剂非数字!!!"
MsgBox smeg, vbOKCancel + vbExclamation, "警告"
Text1(0).Text = ""
Text1(0).SetFocus
Else
If Trim(Text1(1).Text) = "" Then
smeg = "配方名称不能为空!!!"
MsgBox smeg, vbOKCancel + vbExclamation, "警告"
Text1(1).SetFocus
Else
If Trim(Text1(2).Text) = "" Then
smeg = "A添加剂不能为空!!!"
MsgBox smeg, vbOKCancel + vbExclamation, "警告"
Text1(2).SetFocus
Else
If Not IsNumeric(Text1(2).Text) Then
&n
相关文档:
这段时间在移植项目的过程中,起初我想判断一个字符串中是否存在某字符(串),直接的使用方法是用instr(start,string1,string2,VB compare),但经过分析在VB中可以只用一下方法来判断!
1.常用的INStr方法
Function InStr([Start], [String1], [String2], [Compare A ......
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Const EWX_LOGOFF = 0
Private Const EWX_SHUTDOWN = 1
Private Const EWX_REBOOT = 2
Private Const EWX_FORCE = 4
Private closeTime As String
Sub AdjustTokenPrivilegesForNT()
......
作者: 佚名, 出处:IT专家网, 责任编辑: 谢妍妍,
2010-04-23 11:20
本文介绍VB对程序运行的监控。
转眼间,本系列文章已经写到了第六个,今天写点什么呢?
还是得写,看似VB做不到的事情,那么今天起就写写VB对操作系统的控制吧。
首先,说一说,VB对于被调用后的程序的监控方法。
原型函数简 ......
主窗体代码:
'打开网页
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
'复制文件
Private Declare Fu ......
添加2个text,一个command,一个 WebBrowser
Dim vDoc, vTag
Dim i As Integer
Private Sub Command1_Click()
Set vDoc = WebBrowser1.Document
For i = 0 To vDoc.All.length - 1
If UCase(vDoc.All(i).tagName) = "INPUT" Then
Set vTag = vDoc.All(i)
If vTag.Type = "text" Then
Select Case vTag.Nam ......