中易网

vb子窗体如何用代码切换

答案:5  悬赏:20  
解决时间 2021-03-15 08:08
Static lDocumentCount As Long
Dim frmD As frmDocument
lDocumentCount = lDocumentCount + 1
Set frmD = New frmDocument
frmD.Caption = " & lDocumentCount
frmD,获取了子窗体列表后用这段代码添加了N个子窗体,如何点击列表就切换到相应的子窗体;Document "
最佳答案
用show和hide
全部回答
不好意思,我也不知道。
你可以用一个数组对象来保存,,或是一个有规则的关键字,然后通过父窗口的Conotrols来访问
先将窗体名添加到列表框中 在列表框中的click()事件中通过判断,调用相应窗体的加载方法
思路: 程序运行时读取注册表,把读取到的内容对比,看看是否一样,一样则通过,显示主窗体,不一样则不通过。然后在用户单击注册按钮时判断,通过写入相关信息至注册表,并提示成功,否则不写入,并提示失败。 一般情况下软件信息写在注册表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
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
健身体育器材哪个网站质量好。
二人转演员刘小光是否死亡了
权力的游戏第六季多长时间更新一集
晶颖婚纱影楼地址好找么,我有些事要过去
南通中院的法官年薪
微加通 微信加人软件有没有人用过 是不是骗人
既是985又是211工程院校 又有西医临床专业的
MACC是什么啊?MACC和CMA哪个的含金量高,现
玉石婚纱摄影怎么去啊,有知道地址的么
成都高铁站几点停止售票
精神上的虐待属于犯法吗?在那些基础上构成犯
把一个棱长是6cm的正方体木块分割成棱长是2cm
我爸的债主把我的车扣去了!说拿2万元才肯还
集美大学理学院传感器实验室怎么去啊,有知道
中国联通(302省道)地址在什么地方,我要处理
推荐资讯
柴犬六个月毛色还会变吗
从观众的反应来看,我的表演非常成功 翻译成
Excel中图表的源数据可以修改吗
蜂蜜和水哪个重
望峰亭怎么去啊,有知道地址的么
急求;吉林大学宿舍比较好的校区是哪个,都有
小老东牛菜馆怎么去啊,有知道地址的么
哪些地方是镇江市润州区的啊?像三茅宫这类的
跪求.并非清梦的黑篮文《逃生》3部全.《狂狱
篮球现役的亚洲第一人是谁
用友870里面新建帐套后怎样在科目设置里增加
为什么我朋友在中国银行汇款给我、卡号是对的
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?