发布个小软件给大伙玩玩

虽然 VB 已死。。但用来写写桌面小软件还是挺不错的。不过我算是还给了老师。。忘的差不多了。。~~~~~~~~~~


                   很早以前用VB写的。。。也就几行代码。。。。没有一点技术含量
                  下载 无需 安装。。直接运行即可。。
   截图:      
       
r_soft.JPG

下载地址:
http://www.blogjava.net/Files/wujun/mysoft.rar


关键代码:
链接数据库:

ExpandedBlockStart.gif ContractedBlock.gif Public   Function contoserver() Function contoserver() As Boolean '连接数据库函数
InBlock.gif
On Error GoTo Conerror
InBlock.gif    con.CursorLocation 
= adUseClient
InBlock.gif    con.ConnectionString 
= "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & App.Path & "\db.mdb;"
 & "Persist Security Info=False"
InBlock.gif    
'con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Password=wujunainiyiwn;Data Source=E:\数据\vars.mdb;Persist Security Info=True"
InBlock.gif
    con.CommandTimeout = 20
InBlock.gif    con.Open
InBlock.gif    contoserver 
= True
InBlock.gif    
Exit Function
InBlock.gifConerror:
InBlock.gif   
MsgBox "问题,!", vbExclamation + vbOKOnly, "严重问题"
InBlock.gif    contoserver 
= False
ExpandedBlockEnd.gif
End Function

None.gif
ExpandedBlockStart.gifContractedBlock.gif
Public   Function closecon() Function closecon() As Boolean '关闭连接的函数
InBlock.gif
On Error Resume Next
InBlock.gif    
If (Not con Is NothingThen con.Close
InBlock.gif    
Set con = Nothing
ExpandedBlockEnd.gif
End Function

None.gif
ExpandedBlockStart.gifContractedBlock.gif
Public   Function runSQL() Function runSQL(ByVal strsql As StringAs Boolean '执行查询语句的函数
InBlock.gif
On Error GoTo runerror
InBlock.gif    
Set rst = Nothing
InBlock.gif    
Set rst = New ADODB.Recordset
InBlock.gif    rst.Open strsql, con, adOpenDynamic, adLockOptimistic, 
-1
InBlock.gif    runSQL 
= True
InBlock.gif    
Exit Function
InBlock.gifrunerror:
InBlock.gif   
MsgBox "运行这句出错了", vbExclamation + vbOKOnly, "提示"
InBlock.gif
'   MsgBox "错误编号:" & Err.Number & vbCrLf _
InBlock.gif
    & "错误描述:" & Err.Description, vbCritical + vbOKOnly, "连接错误"
InBlock.gif    runSQL 
= False
ExpandedBlockEnd.gif
End Function

None.gif
None.gif

小技巧:

VB 引入超链接按钮
        1.定义
ExpandedBlockStart.gif ContractedBlock.gif Private   Declare   Function ShellExecute() Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA"
 (
ByVal hWnd As LongByVal lpOperation As StringByVal lpFile As StringByVal
lpParameters 
As StringByVal lpDirectory As StringByVal nShowCmd As LongAs Long
InBlock.gif

   2.使用
 
None.gif  ShellExecute  Me .hWnd,  " open " " http://www.blogjava.net/wujun " , vbNullString, vbNullString, vbNormalFocus

textBox 只能输入数字:

ExpandedBlockStart.gif ContractedBlock.gif Private   Sub Text2_KeyPress() Sub Text2_KeyPress(KeyAscii As Integer)
InBlock.gif  
Dim a As Boolean
InBlock.gif
= Chr(KeyAscii) Like "[0-9]" Or KeyAscii = 8
InBlock.gif
If a = False Then
InBlock.gif    KeyAscii 
= 0
InBlock.gif    
MsgBox "这里输入的可是要数字的哦!", vbInformation + vbOKOnly, "提示"
InBlock.gif
End If
ExpandedBlockEnd.gif
End Sub

转载于:https://www.cnblogs.com/wujun/archive/2006/11/18/564829.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值