跪求大俠幫忙寫vb的程式。謝謝了。題目如下。急在

時間 2021-06-12 20:03:10

1樓:況知慧

private sub command1_click()static a as boolean

if a = false then

label1.left = label1.left + 50else

label1.left = label1.left - 50end if

if label1.left + label1.width + 100 > me.width then

a = not a

elseif label1.left < 0 thena = not a

end if

end sub

private sub command2_click()timer1.enabled = not timer1.enabled

end sub

private sub form_load()timer1.enabled = falsetimer1.interval = 100label1.

autosize = truelabel1.caption = "歡迎使用vb"

command1.caption = "手動"

command2.caption = "自動"

end sub

private sub timer1_timer()command1_click

end sub

2樓:匿名使用者

接執行就行了

option explicit

private withevents timer1 as timer

private withevents label1 as label

dim gfangxiang as boolean

dim hwb as single

dim she() as shenti

dim x as long, y as long

dim zhuangtai(23, 23) as long

private type shenti

f as long

x as long

y as long

end type

private sub form_keydown(keycode as integer, shift as integer)

dim c as long

if keycode = 27 then end

if keycode = 32 then

if timer1.enabled = true then

timer1.enabled = false

label1.visible = true

else

timer1.enabled = true

label1.visible = false

end if

end if

c = ubound(she)

if gfangxiang = true then exit sub

select case keycode

case 37

if she(c).f = 2 then exit sub

she(c).f = 0

gfangxiang = true

case 38

if she(c).f = 3 then exit sub

she(c).f = 1

gfangxiang = true

case 39

if she(c).f = 0 then exit sub

she(c).f = 2

gfangxiang = true

case 40

if she(c).f = 1 then exit sub

she(c).f = 3

gfangxiang = true

end select

end sub

private sub form_load()

me.autoredraw = true

me.backcolor = &hc000&

me.fillcolor = 255

me.fillstyle = 0

me.windowstate = 2

set timer1 = controls.add("vb.timer", "timer1")

set label1 = controls.add("vb.label", "label1")

label1.autosize = true

label1.backstyle = 0

label1 = "暫停"

label1.forecolor = rgb(255, 255, 0)

label1.fontsize = 50

chushihua

end sub

private sub form_resize()

on error goto 1:

with me

if .windowstate <> 1 then

.cls

.scalemode = 3

hwb = .scaleheight / .scalewidth

.scalewidth = 24

.scaleheight = 24

label1.move (me.scalewidth - label1.width) / 2, (me.scaleheight - label1.height) / 2

huatu

me.line (x, y)-(x + 1, y + 1), rgb(255, 255, 0), bf

end if

end with

1:end sub

private sub timer1_timer()

dim c as long, i as long

on error goto 2:

qingchu

c = ubound(she)

select case she(c).f

case 0

if zhuangtai(she(c).x - 1, she(c).y) = 2 then

c = c + 1

redim preserve she(c)

she(c).f = she(c - 1).f

she(c).x = she(c - 1).x - 1

she(c).y = she(c - 1).y

chanshengshiwu

goto 1:

elseif zhuangtai(she(c).x - 1, she(c).y) = 1 then

goto 2:

end if

case 1

if zhuangtai(she(c).x, she(c).y - 1) = 2 then

c = c + 1

redim preserve she(c)

she(c).f = she(c - 1).f

she(c).x = she(c - 1).x

she(c).y = she(c - 1).y - 1

chanshengshiwu

goto 1:

elseif zhuangtai(she(c).x, she(c).y - 1) = 1 then

goto 2:

end if

case 2

if zhuangtai(she(c).x + 1, she(c).y) = 2 then

c = c + 1

redim preserve she(c)

she(c).f = she(c - 1).f

she(c).x = she(c - 1).x + 1

she(c).y = she(c - 1).y

chanshengshiwu

goto 1:

elseif zhuangtai(she(c).x + 1, she(c).y) = 1 then

goto 2:

end if

case 3

if zhuangtai(she(c).x, she(c).y + 1) = 2 then

c = c + 1

redim preserve she(c)

she(c).f = she(c - 1).f

she(c).x = she(c - 1).x

she(c).y = she(c - 1).y + 1

chanshengshiwu

goto 1:

elseif zhuangtai(she(c).x, she(c).y + 1) = 1 then

goto 2:

end if

end select

zhuangtai(she(0).x, she(0).y) = 0

for i = 0 to c

select case she(i).f

case 0

she(i).x = she(i).x - 1

case 1

she(i).y = she(i).y - 1

case 2

she(i).x = she(i).x + 1

case 3

she(i).y = she(i).y + 1

end select

next

tiaozheng

1:gfangxiang = false

zhuangtai(she(c).x, she(c).y) = 1

huatu

exit sub

2:if msgbox("遊戲結束,點「是」重新開始遊戲,點「否」", vbyesno, "貪吃蛇") = vbyes then

chushihua

else

endend if

end sub

private sub chushihua()

me.cls

timer1.enabled = true

timer1.interval = 200

erase zhuangtai

redim she(2)

she(0).f = 2

she(0).x = 9

she(0).y = 11

zhuangtai(9, 11) = 1

she(1).f = 2

she(1).x = 10

she(1).y = 11

zhuangtai(10, 11) = 1

she(2).f = 2

she(2).x = 11

she(2).y = 11

zhuangtai(11, 11) = 1

huatu

chanshengshiwu

end sub

private sub qingchu()

dim i as long

for i = 0 to ubound(she)

me.line (she(i).x, she(i).y)-(she(i).x + 1, she(i).y + 1), me.backcolor, bf

next

end sub

private sub huatu()

dim i as long

for i = 0 to ubound(she)

me.circle (she(i).x + 0.5, she(i).y + 0.5), 0.49, rgb(255, 255, 0), , , hwb

next

end sub

private sub tiaozheng()

dim i as long

for i = 0 to ubound(she) - 1

she(i).f = she(i + 1).f

next

end sub

private sub chanshengshiwu()

randomize timer

1:x = int(rnd * 24)

y = int(rnd * 24)

if zhuangtai(x, y) > 0 then goto 1:

zhuangtai(x, y) = 2

me.line (x, y)-(x + 1, y + 1), rgb(255, 255, 0), bf

end sub

跪求c語言大俠 我的位運算程式哪裡出了問題

include int main 我沒有多寫一個函式來實現,是直接在main中實現你所說的功能 做這種題就是要對進位制的轉換要有清楚的認識 short int是2位元組,也就是16位 八進位制 101675 轉換成二進位制則為 001 000 001 110 111 101 因為short int ...

VB6反彙編程式用VB寫的需要將介面上的logo替換掉有什麼辦法麼

1全部首先判斷你的那個exe程式有沒有加殼,如果沒加殼的話就好辦了,有殼要去殼才行 不細說了 vb編譯的exe檔案中,點陣圖都是沒壓縮的,就是位 件多大,存到exe檔案裡就是多大,格式 內容都沒有變化,只要找到位 件在exe檔案中的位置,替換一個新的位 件就可以了 新位 件小了可以,不能比原先的大,...

跪求好看點的小說要格式的請各位大俠幫幫忙

編輯 替換 查詢內容寫上 001 130 替換內容寫上 第一章 第一百三十章 全部替換。可以了。 excel 2003 編輯 替換 高階 查詢內容為 就是在特殊格式中選擇三下任意數專字 替換內容屬為 第 章 第 特殊格式裡面的查詢內容 章 全部替換 如果是txt或者其他格式的,先複製文字到word裡...