當前位置:遊戲中心平台 - 遊戲盒子 - 利用VB做壹個連連看遊戲 我需要完整的VB代碼 要確保能用的 希望能發給我 謝謝大神

利用VB做壹個連連看遊戲 我需要完整的VB代碼 要確保能用的 希望能發給我 謝謝大神

'添加picturebox控件數組,ProgressBar控件和2個timer控件

'搜集自網絡,在d:\新建文件夾下,放10個圖片0個圖片(名字分別為?1.jpg、2.jpg、3.jpg、4.jpg、5.jpg.....10.jpg)

Dim?i?As?Integer?'要建立的圖片框個數

Dim?aa?As?Integer

Dim?gg?As?Integer

Dim?ss?As?Integer

Dim?jj?As?Integer,?hh?As?Integer?'保存聲明窗體的寬度和長度

Dim?tt?As?Integer?'聲明時間變量

Dim?ff?As?Integer

Dim?nn?As?Integer?'聲明圖片框已經隱藏的變量

Dim?kk?As?String

Dim?pp?As?Integer

Dim?j,?uu?As?Integer

Dim?tf?As?Integer,?kl?As?Integer

Dim?oo?As?Integer

Dim?vv?As?Integer

Dim?rr,?mm?As?Integer

Dim?cc?As?Integer

Dim?ee,?qq?As?Integer

Dim?ll?As?Integer

Dim?ww?As?Integer

Dim?a?As?Integer

Dim?mm1,?nn1?As?Integer

Dim?ty,?yt?As?Integer

Dim?strnn?As?String

Dim?strmm?As?String

Private?Sub?Form_Load()

On?Error?GoTo?Myerror

Me.Visible?=?False

pp?=?0

kk?=?".jpg"

ProgressBar1.Max?=?200

Picture1(0).Visible?=?False

For?i?=?1?To?100

pp?=?pp?+?1

If?pp?=?11?Then

pp?=?1

End?If

gg?=?gg?+?1

If?gg?=?10?Then

ss?=?ss?+?Picture1(0).Height?+?50

gg?=?0

aa?=?Picture1(0).Left

hh?=?ss?+?800

Else

aa?=?aa?+?Picture1(0).Width?+?50

jj?=?aa?+?Picture1(0).Width?+?120

End?If

Load?Picture1(i)

Picture1(i).Picture?=?LoadPicture("d:\新建文件夾\"?&?pp?&?kk)

Picture1(i).Width?=?Picture1(0).Width

Picture1(i).Height?=?Picture1(0).Height

Picture1(i).Left?=?aa

Picture1(i).Top?=?ss

Picture1(i).AutoRedraw?=?True

Picture1(i).Visible?=?True

If?i?=?100?Then

Picture1(100).Left?=?Picture1(0).Left

Picture1(100).Top?=?Picture1(0).Top

Picture1(100).Height?=?Picture1(0).Height

Picture1(100).Width?=?Picture1(0).Width

Picture1(100).Visible?=?True

Picture1(100).Picture?=?LoadPicture("d:\新建文件夾\"?&?pp?&?kk)

End?If

Next?i

Me.Width?=?jj

Me.Height?=?hh?-?150

ProgressBar1.Height?=?255

ProgressBar1.Width?=?Me.Width

ProgressBar1.Top?=?hh?-?800

ProgressBar1.Left?=?0

Timer1.Interval?=?500

Timer2.Interval?=?100

Timer1.Enabled?=?False

Randomize?Timer2

tt?=?200

ProgressBar1.Value?=?tt

Exit?Sub

Myerror:

MsgBox?"D:\新建文件夾?文件夾下加載圖片",?vbOKOnly,?"錯誤對話框“"

End

End?Sub

Private?Sub?Picture1_Click(Index?As?Integer)

nn?=?0

pp?=?0

Select?Case?Index

Case?Index

oo?=?oo?+?1

If?oo?=?1?Then

ee?=?Index

For?vv?=?1?To?100

pp?=?pp?+?1

If?pp?=?11?Then

pp?=?1

End?If

If?vv?=?Index?Then

rr?=?vv

tf?=?pp

End?If

Next

End?If

If?oo?=?2?Then

qq?=?Index

For?vv?=?1?To?100

pp?=?pp?+?1

If?pp?=?11?Then

pp?=?1

End?If

If?vv?=?Index?Then

mm?=?vv

kl?=?pp

End?If

Next?vv

oo?=?0

End?If

If?tf?=?kl?Then

If?ee?<>?qq?Then

Picture1(rr).Visible?=?False

Picture1(mm).Visible?=?False

tf?=?0

kl?=?0

End?If

End?If

End?Select

For?i?=?0?To?99

If?Picture1(i).Visible?=?False?Then

nn?=?nn?+?1

End?If

If?nn?=?100?Then

MsgBox?"恭喜!!!?過關了!"

Timer1.Enabled?=?False

End?If

Next?i

End?Sub

Private?Sub?Timer1_Timer()

tt?=?tt?-?1

ProgressBar1.Value?=?tt

If?tt?=?0?Then

ff?=?MsgBox("哈哈?您已經輸了",?vbOKOnly,?"關閉對話框")

If?ff?=?1?Then

End

End?If

End?If

End?Sub

Private?Sub?Timer2_Timer()

a?=?a?+?1

If?a?=?100?Then

Timer2.Enabled?=?False

Timer1.Enabled?=?True

Me.Show

End?If

ll?=?Int(Rnd?*?101)

ww?=?Int(Rnd?*?101)

strnn?=?strnn?+?","?+?Str(ll)

strmm?=?strmm?+?","?+?Str(ww)

If?InStr(ll,?strnn)?=?0?And?InStr(ww,?strmm)?=?0?Then

If?ll?<>?0?And?ww?<>?0?Then

If?ll?<>?ww?Then

mm1?=?Picture1(ll).Left

nn1?=?Picture1(ll).Top

ty?=?Picture1(ww).Left

yt?=?Picture1(ww).Top

Picture1(ll).Left?=?ty

Picture1(ll).Top?=?yt

Picture1(ww).Top?=?nn1

Picture1(ww).Left?=?mm1

End?If

End?If

End?If

End?Sub

  • 上一篇:有什麽好看的總統系列小說?
  • 下一篇:為什麽cosplay是壹種流行的新體驗?
  • copyright 2024遊戲中心平台