似乎可以使用一些子程完成所有步骤
我好像几个月前也写过这个- ‘从你源码里拷贝出来的。。总觉得这样写不是很好,但是无妨。。vb效率也就这样了。。
- Option Explicit
- Public Declare Function GetTickCount Lib "kernel32" () As Long
- Rem 定义中国地名字、外国地名字、单姓、复姓、男名、女名变量
- Public Const c_DiMing = "庵阪邦堡陂边场城陲村岛地巅殿洞坊坟峰府阜冈岗港阁沟谷关观国海河湖江疆界径境郡圹里林岭陵楼陆路麓峦庙墓弄坡丘区塞山省市寺塔台滩潭汀亭土疃屯湾坞县乡崖茔屿峪园苑寨嶂镇冢州渚祝庄"
- Public Const e_DiMing = ""
- Public Const c_XingD = "赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平黄和穆萧尹姚邵湛汪祁毛禹狄米贝明臧计伏成戴谈宋茅庞熊纪舒屈项祝董梁杜阮蓝闵席季麻强贾路娄危江童颜郭梅盛林刁钟徐邱骆高夏蔡田樊胡凌霍虞万支柯昝管卢莫房裘缪干解应宗丁宣贲邓郁单杭洪包诸左石崔吉钮龚程嵇邢滑裴陆荣翁荀羊惠甄曲家封芮羿储靳汲邴糜松井段富巫乌焦巴弓牧隗山谷车侯宓蓬全郗班仰秋仲伊宫宁仇栾暴甘钭历戎祖武符刘景詹束龙叶幸司韶郜黎蓟溥印宿白怀蒲邰从鄂索咸籍赖卓蔺屠蒙池乔阳胥能苍双闻莘党翟谭贡劳逄姬申扶堵冉宰郦雍却璩桑桂濮牛寿通边扈燕冀浦尚农温别庄晏柴瞿阎充慕连茹习宦艾鱼容向古易慎戈廖庾终暨居衡步都耿满弘匡国文寇广禄阙东欧殳沃利蔚越夔隆师巩厍聂晁勾敖融冷訾辛阚那简饶空曾毋沙乜养鞠须丰巢关蒯相查后荆红游竺权逮盍益桓公"
- Public Const c_XingF = "万俟司马上官欧阳夏侯诸葛闻人东方赫连皇甫尉迟公羊澹台公冶宗政濮阳淳于单于太叔申屠公孙仲孙轩辕令狐徐离宇文长孙慕容司徒司空亓官司寇仉督子车颛孙端木巫马公西漆雕乐正"
- Public Const c_MingM1 = "安邦宝保彪彬斌波伯博才策昌超琛辰晨成承诚春达德东栋发飞风峰福富刚罡功固冠光广贵国海翰航豪浩和河恨亨恒弘宏鸿厚华辉会家坚建健江杰金进敬军钧俊康克朗乐磊力利良梁亮林龙伦轮茂民明鸣楠宁朋鹏平奇启谦强清庆全群仁荣榕若山善绍生胜盛时士世树顺思松泰涛腾天维伟文武先祥翔小心新信兴星行雄旭学言岩炎以义毅永勇友有玉裕元泽哲振震政之志致中忠壮子"
- Public Const c_MingM2 = ""
- Public Const c_MingM3 = ""
- Public Const c_MingM4 = ""
- Public Const c_MingW1 = "爱安傲白柏半宝贝蓓碧璧冰波采彩婵痴初春纯聪翠代黛丹娣蝶冬娥儿尔凡梵芳飞菲芬风枫凤芙馥谷桂海含涵寒菡荷恨红华骅桦怀槐欢环幻卉惠慧姬寄佳嘉剑姣娇洁婕金锦瑾菁晶静菊娟君筠苛可兰岚蓝澜乐蕾冷莉丽荔怜莲琳灵玲凌菱柳露璐绿玛曼眉梅美妹媚梦觅妙茗慕娜南妮念凝盼沛佩飘平萍琦琪绮千茜倩巧芹琴勤青卿清晴琼秋荣容蓉融柔如蕊瑞睿若莎山珊诗书淑舒双霜爽水烁丝思松素堂桃婷彤纨宛婉琬薇苇文雯问希惜霞夏贤娴香向霄小晓笑欣新馨秀萱旋雪寻雅娅烟妍琰彦艳雁燕阳洋瑶叶夜伊依仪宜怡以忆艺亦易逸英莺迎滢颖影映咏友又幼宇羽雨语玉育毓元园苑媛瑗月悦阅云芸韵昭贞珍真之芝枝芷忠珠竹紫宗醉"
- Public Const c_MingW2 = ""
- Public Const c_MingW3 = ""
- Public Const c_MingW4 = ""
- Rem 定义随机取好的单姓,复姓、男名首字,男名尾字,女名首字,女名尾字,地名用字
- Public StrA As String
- Public StrB As String
- Public StrC As String
- Public StrD As String
- Public StrE As String
- Public StrF As String
- Public StrG As String '取字符串
- Rem 定义字符串、男姓名、女姓名、
- Public AllMstr As String
- Public AllWstr As String
- ‘********************************************************************
- Public Function rndInt(x1 As Long, x2 As Long) As Long
- Randomize
- rndInt = Int(Rnd * (Int(x2) - Int(x1) + 1)) + x1
- End Function
- Public Sub SplitWords(ByVal SplitString As String, Splitn() As String, SplitStep As Long)
- Dim i As Long
- ReDim Splitn(Len(SplitString) / SplitStep - 1)
- For i = 1 To Len(SplitString) Step SplitStep
- Splitn((i - 1) / SplitStep) = Mid(SplitString, i, SplitStep)
- Next i
- End Sub
- Public Function RndString(Splitn() As String) As String
- RndString = Splitn(rndInt(0, UBound(Splitn)))
- End Function
- ’*****************************************************************
复制代码 放在模块里、、
初始化的时候,调用- Private Sub Form_Load()
- 'single
- SplitWords c_XingD, c_XingD_N, 1
- 'double
- SplitWords c_XingF, c_XingF_N, 2
- 'male
- SplitWords c_MingM1, c_MingM1_N, 1
- 'female
- SplitWords c_MingW1, c_MingW1_N, 1
- End Sub
复制代码 之后显示人名只需要- If Option1.Value = True Then
- For i = 0 To 100 - 1
- List1.AddItem RndString(c_XingF_N) & " " & RndString(c_MingW1_N)
- Next i
- Else
- For i = 0 To 100 - 1
- List1.AddItem RndString(c_XingD_N) & " " & RndString(c_MingW1_N)
- Next i
- End If
复制代码 代码几乎没有优化
tickcont的时间是16(似乎就是不耗时间)。。。
抛砖引玉,个人对优化方面理解不深
|