Static lDocumentCount As Long
Dim frmD As frmDocument
lDocumentCount = lDocumentCount + 1
Set frmD = New frmDocument
frmD.Caption = " & lDocumentCount
frmD,获取了子窗体列表后用这段代码添加了N个子窗体,如何点击列表就切换到相应的子窗体;Document "
vb子窗体如何用代码切换
答案:5 悬赏:20
解决时间 2021-03-15 08:08
- 提问者网友:挣扎重来
- 2021-03-14 09:00
最佳答案
- 二级知识专家网友:恕我颓废
- 2021-03-14 10:07
用show和hide
全部回答
- 1楼网友:你把微笑给了谁
- 2021-03-14 14:04
不好意思,我也不知道。
- 2楼网友:瘾与深巷
- 2021-03-14 13:32
你可以用一个数组对象来保存,,或是一个有规则的关键字,然后通过父窗口的Conotrols来访问
- 3楼网友:单身小柠`猫♡
- 2021-03-14 12:01
先将窗体名添加到列表框中
在列表框中的click()事件中通过判断,调用相应窗体的加载方法
- 4楼网友:心痛成瘾
- 2021-03-14 10:36
思路:
程序运行时读取注册表,把读取到的内容对比,看看是否一样,一样则通过,显示主窗体,不一样则不通过。然后在用户单击注册按钮时判断,通过写入相关信息至注册表,并提示成功,否则不写入,并提示失败。
一般情况下软件信息写在注册表hkey_local_machine下的software里。
例子:
private sub form_load()
a = getstring(hkey_local_machine, "software\我的程序", "注册信息")
if a = "" then setstring hkey_local_machine, "software\我的程序", "注册信息", "null"
if a ……………………… then '省略号里面的内容看你怎么写了,就是通过验证的代码
unload me
form2.show
end if
end sub
private sub 注册按钮_click()
if text1.text………………………………………… then '和上面的a一样
setstring hkey_local_machine, "software\我的程序", "注册信息", text1.text
unload me
form2.show
msgbox "注册成功"
else
msgbox "注册失败"
end if
end sub
给你一个读写注册表的模块。不管在你这个程序中用了多少,以后也会有用的。
'================================
'注册表通用操作函数
'================================
'==================================================
'注册表操作声明
public declare function regopenkey lib "advapi32.dll" alias "regopenkeya" (byval hkey as long, byval lpsubkey as string, phkresult as long) as long
public declare function regenumvalue lib "advapi32.dll" alias "regenumvaluea" (byval hkey as long, byval dwindex as long, byval lpvaluename as string, lpcbvaluename as long, byval lpreserved as long, lptype as long, lpdata as byte, lpcbdata as long) as long
public declare function regclosekey lib "advapi32.dll" (byval hkey as long) as long
public declare function regcreatekey lib "advapi32.dll" alias "regcreatekeya" (byval hkey as long, byval lpsubkey as string, phkresult as long) as long
public declare function regqueryvalueex lib "advapi32.dll" alias "regqueryvalueexa" (byval hkey as long, byval lpvaluename as string, byval lpreserved as long, lptype as long, lpdata as any, lpcbdata as long) as long
public declare function regenumkeyex lib "advapi32.dll" alias "regenumkeyexa" (byval hkey as long, byval dwindex as long, byval lpname as string, lpcbname as long, byval lpreserved as long, byval lpclass as string, lpcbclass as long, lpftlastwritetime as any) as long
public declare function regsetvalueex lib "advapi32.dll" alias "regsetvalueexa" (byval hkey as long, byval lpvaluename as string, byval reserved as long, byval dwtype as long, lpdata as any, byval cbdata as long) as long
public declare function regdeletevalue lib "advapi32.dll" alias "regdeletevaluea" (byval hkey as long, byval lpvaluename as string) as long
public declare function regdeletekey lib "advapi32.dll" alias "regdeletekeya" (byval hkey as long, byval lpsubkey as string) as long
public const hkey_classes_root = &h80000000
public const hkey_current_user = &h80000001
public const hkey_local_machine = &h80000002
public const hkey_users = &h80000003
private const reg_sz = 1&
private const reg_expand_sz = 2&
private const reg_binary = 3&
private const reg_dword = 4&
private const error_success = 0&
'==================================================
'================================
'注册表操作函数
'================================
'读取注册表字符串键值
public function getstring(hkey as long, strpath as string, strvalue as string)
dim keyhand as long
dim lresult as long
dim strbuf as string
dim ldatabufsize as long
dim intzeropos as integer
dim lvaluetype as long 'new add
regopenkey hkey, strpath, keyhand
lresult = regqueryvalueex(keyhand, strvalue, 0&, lvaluetype, byval 0&, ldatabufsize)
if lvaluetype = reg_sz or lvaluetype = reg_expand_sz then
strbuf = string(ldatabufsize, " ")
lresult = regqueryvalueex(keyhand, strvalue, 0&, lvaluetype, byval strbuf, ldatabufsize)
if lresult = error_success then
intzeropos = instr(strbuf, chr$(0))
if intzeropos > 0 then
getstring = left$(strbuf, intzeropos - 1)
else: getstring = strbuf
end if
end if
end if
end function
'写入注册表字符串键值
public sub setstring(hkey as long, strpath as string, strvalue as string, strdata as string)
dim keyhand as long
regcreatekey hkey, strpath, keyhand
regsetvalueex keyhand, strvalue, 0, reg_sz, byval strdata, len(strdata)
regclosekey keyhand
end sub
'读取注册表 dword 键值
function getdword(byval hkey as long, byval strpath as string, byval strvaluename as string) as long
dim lresult as long
dim lvaluetype as long
dim lbuf as long
dim ldatabufsize as long
dim r as long
dim keyhand as long
r = regopenkey(hkey, strpath, keyhand)
' get length/data type
ldatabufsize = 4
lresult = regqueryvalueex(keyhand, strvaluename, 0&, lvaluetype, lbuf, ldatabufsize)
if lresult = error_success then
if lvaluetype = reg_dword then
getdword = lbuf
end if
'else
' call errlog("getdword-" & strpath, false)
end if
r = regclosekey(keyhand)
end function
'写入注册表 dword 键值
function setdword(byval hkey as long, byval strpath as string, byval strvaluename as string, byval ldata as long)
dim keyhand as long
regcreatekey hkey, strpath, keyhand
regsetvalueex keyhand, strvaluename, 0&, reg_dword, ldata, 4
regclosekey keyhand
end function
'读取注册表二进制键值
function getbinary(byval hkey as long, byval strpath as string, byval strvaluename as string) as long
dim lresult as long
dim lvaluetype as long
dim lbuf as long
dim ldatabufsize as long
dim r as long
dim keyhand as long
r = regopenkey(hkey, strpath, keyhand)
' get length/data type
ldatabufsize = 4
lresult = regqueryvalueex(keyhand, strvaluename, 0&, lvaluetype, lbuf, ldatabufsize)
if lresult = error_success then
if lvaluetype = reg_binary then
getbinary = lbuf
end if
end if
r = regclosekey(keyhand)
end function
'写入注册表二进制键值
function setbinary(byval hkey as long, byval strpath as string, byval strvaluename as string, byval ldata as long, byval bitnumber as long)
dim keyhand as long
regcreatekey hkey, strpath, keyhand
regsetvalueex keyhand, strvaluename, 0&, reg_binary, ldata, bitnumber
regclosekey keyhand
end function
'删除一个注册表键值
public function deletevalue(byval hkey as long, byval strpath as string, byval strvalue as string)
dim keyhand as long
regopenkey hkey, strpath, keyhand
regdeletevalue keyhand, strvalue
regclosekey keyhand
end function
'创建一个主键
public function createkey(byval hkey as long, byval strkey as string)
dim keyhand&
regcreatekey hkey, strkey, keyhand
regclosekey keyhand&
end function
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯