建立 VPN 拨号全部代码如下:
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Private Type RASIPADDR
a As Byte
b As Byte
c As Byte
d As Byte
End Type
Private Type RASENTRY
dwSize As Long
dwfOptions As Long
dwCountryID As Long
dwCountryCode As Long
szAreaCode(10) As Byte
szLocalPhoneNumber(128) As Byte
dwAlternateOffset As Long
ipaddr As RASIPADDR
ipaddrDns As RASIPADDR
ipaddrDnsAlt As RASIPADDR
ipaddrWins As RASIPADDR
ipadd ......
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Private Type RASIPADDR
a As Byte
b As Byte
c As Byte
d As Byte
End Type
Private Type RASENTRY
dwSize As Long
dwfOptions As Long
dwCountryID As Long
dwCountryCode As Long
......
Imports System.Data.OleDb
Inherits System.Windows.Forms.Form
Dim myconnection As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" & Application.StartupPath & "\student0.mdb") ‘------------------------- 链接数据库
Dim mycommand As OleDbCommand
Dim mydatareader As OleDbDataReader
在别的事件中打开表
myconnection.Open()
mycommand = New OleDbCommand("SELECT * from 管理员表 where username='" & Trim(Txt_Username.Text) & "'and password='" & Trim(Txt_pwd.Text) & "'", myconnection)
mydatareader = mycommand.ExecuteReader() ......
Imports System.Data.OleDb
Inherits System.Windows.Forms.Form
Dim myconnection As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" & Application.StartupPath & "\student0.mdb") ‘------------------------- 链接数据库
Dim mycommand As OleDbCommand
Dim mydatareader As OleDbDataReader
在别的事件中打开表
myconnection.Open()
mycommand = New OleDbCommand("SELECT * from 管理员表 where username='" & Trim(Txt_Username.Text) & "'and password='" & Trim(Txt_pwd.Text) & "'", myconnection)
mydatareader = mycommand.ExecuteReader() ......
无意中发现VB For循环的一个特点:在循环体中,企图改变循环终止变量使之提前退出循环是徒劳的。
Private Sub Form_Load()
Dim s(0 To 4) As String
Dim N As Integer, i As Integer
s(0) = "测试1"
s(1) = "测试2"
s(2) = "测试3"
s(3) = "测试4"
s(4) = "测试5"
N = 4
For i = 0 To N
'在循环体中,企图改变循环终止变量使之提前退出循环是徒劳的。
'只有 判断【循环变量】是否大于【循环终止变量】来提前退出才是可行的,如:If i > N Then Exit For
Debug.Print s(i)
If i = 0 Or i = 3 Then N = N - 1
Next i
MsgBox "i====" & i & " N==" & N
End Sub ......
'添加个picture1和command1
Option Explicit
Dim lngCenter As Long
Dim lngMax As Long
Dim lngPad&
Dim PCurrent As POINT, PLast As POINT
Private Type POINT
x As Long
y As Long
End Type
Private Sub Form_Load()
lngCenter = (Picture1.Top + Picture1.Height) / 2
lngMax = Picture1.Height
PLast.x = 0
PLast.y = lngCenter
Dim i&
For i = 0 To Picture1.Width Step 100
Picture1.Line (i, 0)-(i, Picture1.Height), &HFFC0C0
Next
For i = 0 To Picture1.Height Step 100
Picture1.Line (0, i)-(Picture1.Width, i), &HFFC0C0
Next
Picture1.DrawWidth = 1.5
Picture1.Line (0, lngCenter)-(Picture1.Width, lngCenter), vbBlue
Picture1.DrawWidth = 1
End Sub
Private Sub Timer1_Timer()
PCurrent.x = PCurrent.x + 50
Randomize
PCurrent.y = Rnd * lngMax
Picture1.Line (PCurrent.x, PCurrent.y)-(PLast.x, PLast.y), vbRed
PLast.x = PCurrent.x
PLast.y = PCurrent.y
......
http://zhidao.baidu.com/question/84802747.html
VB如何获取窗口地址栏内容
就是比如我打开D盘的aaa文件夹,窗口地址栏就是显示D:\aaa,请问我要怎么用VB写程序来获取窗口地址栏的内容?(不是IE的地址栏)
若打开了两个窗口,比如D盘的aaa文件夹和E盘的bbb文件夹下的ccc文件夹都打开的话,点击command1,text1就显示:
D:\aaa
E:\bbb\ccc
请大家帮忙下,谢谢!
Private Const GW_HWNDNEXT = 2
Private Const GW_HWNDFIRST = 0
Private Const WM_GETTEXT = &HD
Private Declare Function GetNextWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wFlag As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private De ......