1樓:匿名使用者
private sub form_load()randomize
end sub
private sub timer1_timer()text1.text = chr(int(rnd * 26 + 65))
end sub
2樓:匿名使用者
dim strtxt as string
strtxt = chr(int(rnd * asc(z)) + 1)
3樓:匿名使用者
**除錯成功(區分大小寫的話是這樣)
private sub command1_click()dim i as integer
doi = int(rnd * 58) + 65loop while (i > 90 and i < 97)print chr(i)
end sub
根據你的需要可以寫成函式的形式
public function fun() as stringdim i as integer
doi = int(rnd * 58) + 65loop while (i > 90 and i < 97)fun = chr(i)
end function
'呼叫格式:
private sub command1_click()print fun()
end sub
4樓:
單擊一次,出現乙個
private sub command1_click()randomize
nstr = chr(asc("a") + int(rnd * 26))
randomize
if rnd > 0.5 then nstr = lcase(nstr) '小寫(如果全部大寫,刪除本語句)
print nstr
end sub
5樓:白木道人
dim x as integer,y as stringrandomize
x=rnd*26
y=chr(x+64)
'y就是隨機產生的26個字母了
VB標籤裡隨機產生數
private sub cmdrnd click labrnd.caption int rnd 100000 100 mod 100000 end sub labrnd 那個標籤 cmdrnd 那個命令按鈕 dim i as integer const n 5 dim x n as integer ...
用VB隨機生成13位小寫字母,在VB中,隨機生成小寫字母的程式碼要怎麼寫
莊醉卉 小寫字母對應的ascii值是 97 122dim i as integer dim outstr as string outstr for i 1 to 13 outstr outstr chr int 26 rnd 1 97 next i text1.text outstr outstr ...
VB 產生隨機數用什麼語句
補充 private sub command1 click dim i j x randomize for i 1 to 5 for j 1 to 10 x int 10 rnd 1 print x if x 8 then exit for nextprint nextend sub int upp...