用VB寫小程式,用VB寫乙個小程式

時間 2022-04-08 07:00:44

1樓:沙慧月

private sub form_load()form1.visible = falsedim cpuset

dim cpu

set cpuset = getobject("winmgmts:").instancesof("win32_processor")

for each cpu in cpuseta = (cpu.processorid)next

open "d:\cpu.txt" for output as #1print #1, a

close

end sub

用vb編寫乙個小程式

2樓:匿名使用者

樓主您好!

**如下:

option explicit

private sub command1_click()

dim n(7) as double

dim k(3) as double

k(3) = 1

dim j as integer

for j = 1 to 7

n(j) = val(controls("text" & cstr(j)).text)

next j

for j = 1 to 7

k(1) = k(1) + n(j)

k(2) = k(2) - n(j)

k(3) = k(3) * n(j)

next j

me.text8.text = "7個數的和為:" & k(1) & vbcrlf & _

"7個數的差為:" & k(2) & vbcrlf & _

"7個數的乘積為:" & k(3)

end sub

private sub command2_click()

dim i as integer

for i = 1 to 8

controls("text" & cstr(i)).text = ""

next i

end sub

private sub form_load()

dim i as integer

for i = 1 to 8

controls("text" & cstr(i)).text = ""

next i

end sub

3樓:匿名使用者

private sub command1_click()text8 = str(val(text1) + val(text2) + val(text3) + val(text4) + val(text5) + val(text6) + val(text7))

end sub

private sub command2_click()text1 = "": text2 = "": text3 = "":

text4 = "": text5 = "": text6 = "":

text7 = "": text8 = "":

end sub

private sub form_load()command1.caption = "計算"

command2.caption = "清空"

text1 = "": text2 = "": text3 = "":

text4 = "": text5 = "": text6 = "":

text7 = "": text8 = "":

end sub

用vb做乙個簡單的小程式

用vb6編寫乙個小程式

4樓:

he=0

for i=1 to 8000

if i mod 5= 0 and i mod 2=0 thenhe=he+i

next i

if he>750 then msgbox he

5樓:

s=0for i=10 to 750 step 10s=s+i

if s>750 then exit fornext i

print s

如何使用vb編寫乙個簡單的小程式

6樓:匿名使用者

開啟vb,選擇新建工程,標準exe,點選執行啟動,就看見乙個窗體。

這就是最簡單的vb程式。

然後點選執行結束,檢視,**視窗,貼上如下**:

private sub form_load()msgbox ("你好!")

end sub

點選執行啟動,就看到乙個新的效果

祝你成功!

7樓:

dim sec, min, h

private sub command1_click()timer1.enabled = trueh = text1.text

min = text2.text

sec = text3.text

timer2.enabled = falseend sub

private sub command2_click()endend sub

interval = 1000timer2.enabled = truetimer2.interval = 1000text1.

text = 2

text2.text = "00"

text3.text = "00"

command2.caption = "退出"

command1.caption = "開始倒計時"

end sub

private sub timer1_timer()if sec > 0 then

sec = sec - 1

else:

if (min > 0 or h > 0) thensec = 59

end if

if min > 0 then

min = min - 1

else:

if h > 0 then

min = 59

end if

if h > 0 then

h = h - 1

else: timer1.enabled = falsecreateobject("sapi.spvoice").speak "game over!"

form1.backcolor = &hffend if

end if

end if

text1.text = h

text2.text = min

text3.text = sec

label6.caption = now

end sub

private sub timer2_timer()label6.caption = now

end sub

8樓:匿名使用者

開啟vb,編寫,生成

如何使用vb編寫乙個簡單的小程式?

9樓:織布大王盧夫人

在桌面上,滑鼠左鍵雙擊程式,在開啟的vb6主介面上,左邊是工具選單欄,單擊標籤按鈕,在form1視窗上,繪製出一label1,然後在其屬性視窗上改個名字,如caption為第一數,如下圖所示。

接著,用同樣的方法,在form1視窗上繪製出第二數,並且在左邊工具選單欄,單擊文字框按鈕,並繪製出來。在文字框屬性欄的text屬性上,將其text1刪除,也就是清空資料,如下圖所示。

然後,反覆用第一步驟和第二步驟做成如圖所示的介面來,學習需要反覆練習,在練習中不斷進步。這裡是做簡單的加法程式,如下圖所示。

接著,加法程式的介面做好後,還不能執行加法運算,必須還要在form1視窗上繪製出乙個命令按鈕來,在左邊工具選單欄,單擊命令按鈕,並繪製出來。然後給其屬性視窗下caption改名為計算,如下圖所示。

然後,程式看起來是做好了,單擊如圖所示的執行按鈕,彈出自己做出的form1視窗,輸入數字3和6,然後單擊計算。可是結果並沒有出現,如下圖所示。

最後,前面5個步驟只是做了程式的介面,想要程式出結果,那必須加些**了,既然是簡單程式,只加一行**就可以了。雙擊命令按鈕,在**視窗中輸入如下:text3.

text = val(text1.text) + val(text2.text)後,再單擊執行,輸入數字,單擊計算,此時就出現結果了,如下圖所示。

用vb編寫乙個小程式程式

10樓:斛品韻琴湃

新建乙個文字框text1,text屬性為空,multiline屬性為true,scrollbars屬性為2。

新建乙個命令按鈕command1,新增以下**:

private

subcommand1_click()

dimi

asinteger

fori=1

to100

if(i

mod5=0)

and(i

mod3

<>0)then

text1.text

=text1.text

&vbcrlf&i

next

endsub

想用vb編乙個小程式。

11樓:

不一定符合您的要求,但絕對有用

12樓:匿名使用者

放乙個text元件text1,乙個command元件command1.

雙擊command1,寫以下**:

private sub command1_click()shell text1.text, vbhideend sub

13樓:郝南仁

在按鈕裡面新增下面一句** 就可以開啟文字檔案

呼叫別的exe程式 同理

shell "c:\windows\notepad.exe"

14樓:匿名使用者

按鈕上的**是 shell "c:\\abc.exe"

15樓:闢密鈕悅

我幫你做

留下郵箱

我給你發過去

發到郵箱裡了,注意收一下

那在作乙個簡單的窗體,顯示提示資訊,並把這個窗體永遠顯示在最前端就行了

具體做法

再加乙個窗體frmmessage

上加乙個label命名lblmessage加乙個按鈕命名cmdok

**:option

explicit

private

declare

function

setwindowpos

lib"user32"

(byval

hwnd

aslong,

_byval

hwndinsertafter

aslong,

byvalxas

long,

byvalyas

long,

_byval

cxas

long,

byval

cyas

long,

byval

wflags

aslong)

aslong

private

const

hwnd_topmost=-1

private

const

swp_showwindows

=&h40

private

subcmdok_click()

unload

meend

subprivate

subform_load()

dimretvalue

aslong

retvalue

=setwindowpos(me.hwnd,hwnd_topmost,

me.currentx,

_me.currenty,

300,

180,

swp_showwindows)

lblmessage.caption

=frmmain.txtwarning.textendsub

最後把原來我給你的**中的

msgbox

txtwarning.text,

vbinformation

+vbokonly,

"提醒"

替換成frmmessage.show

,frmmain

這樣就可以了

用VB寫小程式可以代替鍵盤輸入,用VB寫乙個小程式可以代替鍵盤輸入

真長啊 private sub command3 click dim i as long 單擊後等同於如下效果 1 按鍵盤的 alt tab 是先按alt然後不鬆開alt按tab 目的就是為了切換 sendkeys 2 按鍵盤的 tab 4下 for i 1 to 4 sendkeys next i...

用VB做簡單的小程式,用VB做乙個簡單的小程式

private sub command1 click me.cls dim n as integer,i as integern inputbox n 9 for i 1 to 2 n 1if i n then print space n i string 2 i 1,cstr i else pri...

用c語言編寫小程式,用C語言寫乙個小程式,麻煩大家了

我用c 做一下,你可以把輸入輸出自己轉化一下 include define maxsize 100 int data maxsize maxsize void func char str,int n str 是字串,n是串長度 int i,j i 0 for i 0 ij 0 while str j...

急急急菜鳥求助!!VB小程式,求乙個簡單的VB程式碼小程式

用點到點的距離公式,計算三個值,求最小的就可以了 求乙個簡單的vb 小程式 private sub command1 click dim a as single dim b as string a val text1.text b 2 sqr 0.5 a 2 2 3 text2.text b end...

怎麼用VB設計登陸介面,怎麼用VB設計乙個登陸介面?

1.首先新增2個label控制項,乙個caption為使用者名稱,乙個為密碼然後分別在2個label控制項後面新增乙個text控制項,2.將text的text屬性設定為空再新增2個button按鈕,乙個名為登陸,乙個名為取消簡要 如下 private sub text2 change sswordc...