发布个小软件给大伙玩玩
虽然 VB
已死。。但用来写写桌面小软件还是挺不错的。不过我算是还给了老师。。忘的差不多了。。~~~~~~~~~~
很早以前用VB写的。。。也就几行代码。。。。没有一点技术含量
下载 无需 安装。。直接运行即可。。
截图:
下载地址:
http://www.blogjava.net/Files/wujun/mysoft.rar
关键代码:
链接数据库:
小技巧:
VB 引入超链接按钮
1.定义
2.使用
textBox 只能输入数字:
很早以前用VB写的。。。也就几行代码。。。。没有一点技术含量
下载 无需 安装。。直接运行即可。。
截图:
下载地址:
http://www.blogjava.net/Files/wujun/mysoft.rar
关键代码:
链接数据库:
Public Function contoserver() As Boolean '连接数据库函数
On Error GoTo Conerror
con.CursorLocation = adUseClient
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & App.Path & "\db.mdb;"
& "Persist Security Info=False"
'con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Password=wujunainiyiwn;Data Source=E:\数据\vars.mdb;Persist Security Info=True"
con.CommandTimeout = 20
con.Open
contoserver = True
Exit Function
Conerror:
MsgBox "问题,!", vbExclamation + vbOKOnly, "严重问题"
contoserver = False
End Function
Public Function closecon() As Boolean '关闭连接的函数
On Error Resume Next
If (Not con Is Nothing) Then con.Close
Set con = Nothing
End Function
Public Function runSQL(ByVal strsql As String) As Boolean '执行查询语句的函数
On Error GoTo runerror
Set rst = Nothing
Set rst = New ADODB.Recordset
rst.Open strsql, con, adOpenDynamic, adLockOptimistic, -1
runSQL = True
Exit Function
runerror:
MsgBox "运行这句出错了", vbExclamation + vbOKOnly, "提示"
' MsgBox "错误编号:" & Err.Number & vbCrLf _
& "错误描述:" & Err.Description, vbCritical + vbOKOnly, "连接错误"
runSQL = False
End Function
On Error GoTo Conerror
con.CursorLocation = adUseClient
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & App.Path & "\db.mdb;"
& "Persist Security Info=False"
'con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Password=wujunainiyiwn;Data Source=E:\数据\vars.mdb;Persist Security Info=True"
con.CommandTimeout = 20
con.Open
contoserver = True
Exit Function
Conerror:
MsgBox "问题,!", vbExclamation + vbOKOnly, "严重问题"
contoserver = False
End Function
Public Function closecon() As Boolean '关闭连接的函数
On Error Resume Next
If (Not con Is Nothing) Then con.Close
Set con = Nothing
End Function
Public Function runSQL(ByVal strsql As String) As Boolean '执行查询语句的函数
On Error GoTo runerror
Set rst = Nothing
Set rst = New ADODB.Recordset
rst.Open strsql, con, adOpenDynamic, adLockOptimistic, -1
runSQL = True
Exit Function
runerror:
MsgBox "运行这句出错了", vbExclamation + vbOKOnly, "提示"
' MsgBox "错误编号:" & Err.Number & vbCrLf _
& "错误描述:" & Err.Description, vbCritical + vbOKOnly, "连接错误"
runSQL = False
End Function
小技巧:
VB 引入超链接按钮
1.定义
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
(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
2.使用
ShellExecute Me.hWnd, "open", "http://www.blogjava.net/wujun", vbNullString, vbNullString, vbNormalFocus
textBox 只能输入数字:
Private Sub Text2_KeyPress(KeyAscii As Integer)
Dim a As Boolean
a = Chr(KeyAscii) Like "[0-9]" Or KeyAscii = 8
If a = False Then
KeyAscii = 0
MsgBox "这里输入的可是要数字的哦!", vbInformation + vbOKOnly, "提示"
End If
End Sub
Dim a As Boolean
a = Chr(KeyAscii) Like "[0-9]" Or KeyAscii = 8
If a = False Then
KeyAscii = 0
MsgBox "这里输入的可是要数字的哦!", vbInformation + vbOKOnly, "提示"
End If
End Sub
posted on 2006-11-18 22:34 hello csharp 阅读(824) 评论(0) 编辑 收藏 举报
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步