当前位置:首页 > 代码 > 正文

vb连连看代码(vb连等会出现什么情况)

admin 发布:2022-12-19 02:27 121


本篇文章给大家谈谈vb连连看代码,以及vb连等会出现什么情况对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

在vb中,像连连看一样在图片框中随机产生图片,用代码怎样实现?

用随机函数rnd。和int函数一起使用,产生随机整数,然后根据所产生的随机数确定图片框所对应的图片。

vb 编写简单连连看

试试吧:

Option Explicit

'添加一个picture1(0),2个时钟控件 滚动条 ,窗体2 (form2为启动窗口)

'请在D:\新建文件夹 文件夹下加载10个图片(名字分别为 1、2、3、4、5.....10)

'虽然做的不好 却是用心去做的 以修改了随即问题!

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

form2.hide

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

求一个VB程序代码,连连看的,谢谢

' '以下代码在 VB6 调试通过。

'一.将以下代码全部复制到窗体代码窗口内'以下代码在 VB6 调试通过。

'二.为窗体添加菜单

' 添加菜单 mFast,并为 mFast 添加子菜单 mmFast 和 mmTu

' 为 mmTu 添加子菜单 mmPic

' 将菜单 mmFast 和 mmPic 的索引设置为 0,其他属性不必设置。菜单结构如下:

' mFast

' ....mmFast 索引(index 属性)设置为 0

' ....mmTu

' ........mmPic 索引(index 属性)设置为 0

'三.在窗体中添加 7 个控件

' 4 个数组控件:Image1,Shape1,Label1,Line1,并将这四个控件的 Index 属性设置为 0

' 3 个单独控件:Picture1,Dir1,Timer1,都不用设置任何属性

'四.默认使用系统图标图案,如果要使用自己设置的图片(Ico文件),在工程所在目录下新建一个文件夹 Tu ,

' 在 Tu 下可建立多个文件夹,如“国旗”、“交通标准”等,然后将相应图标文件

' 放到其中,每个文件夹可放置 100 个文件。

Private Type tyTu

ImageNum As Integer 'Image 控件序号

Tu As Long '图片序号

Visible As Boolean '是否可见

End Type

Enum enTo

to_Up

to_Down

to_Left

to_Right

End Enum

Enum enTai

tai_Stop

tai_Play

tai_Auto

tai_Step

End Enum

Dim ctTu() As tyTu, ctH As Long, ctL As Long, ctGD() As Long, ctGDs As Long, ctBusy As Boolean '忙

Dim ctPicMax As Long, ctPicS As Long, ctPic() As Picture, ctNotePic() As String, ctSeBack() As Long

Dim ctTuType As String, ctSize As Long, ctX As Long, ctY As Long, ctTai As enTai

Dim ctHide() As Long, ctHideS As Long, ctStep As Long, ctStr As String, ctRefresh As Boolean

Dim ctMaxGD As Long, ctFen As Long, ctLife As Long, ctNote As Long

Dim ctFlashCi As Long, ctWait As Boolean, ctExit As Boolean

Private Declare Function DrawIconEx Lib "user32" (ByVal hdc As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long

Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long

Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long

Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)

Private Function GetIcoToZu(nIco As String, Optional ReRead As Boolean) As Long

'提取图片,存入 ctPic(),并设置 ctNotePic()

Static UpIco As String

Dim F As String, S As Long, IcoID As Long, dl As Long, nPicS As Long

Dim nL As Long, nT As Long, pW As Long, pH As Long, nW As Long, nH As Long

Dim nPath As String, I As Long

If ReRead Then UpIco = "" '无条件重新读取图片文件

If UpIco = nIco Then GetIcoToZu = UBound(ctPic): Exit Function

UpIco = nIco

pW = Picture1.ScaleX(ctSize, Picture1.ScaleMode, 3) '转为像素

pH = Picture1.ScaleY(ctSize, Picture1.ScaleMode, 3) '转为像素

nW = 32: nH = 32

If pW 32 Then nW = pW

If pH 32 Then nH = pH

ReDim ctPic(1 To 1): ReDim ctNotePic(1 To 1)

Picture1.Move 0, 0, ctSize, ctSize

Picture1.Picture = LoadPicture()

利用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

vb 连连看游戏代码要全部的

Picture1(I);

F

=

UpI

And

UpI

;MyTu,

Picture1(Index).Tag

=

Picture1(UpI);选中一个图片

UpI

=

Index

Label1.AutoRedraw

=

True

For

I

=

To

10

If

I

;

I

S

:

Label1.Width

*

1;图片相同

Picture1(Index).ico.Caption

=

Then

Load

Picture1(I);C.1.Height

*

1。下面是例子.Print

tuquot:---------------------------------

在窗体放置控件

Picture1;.Tag

=

quot.1;tu

S

Picture1(I)、

tu3.Height

*

0.Visible

=

False.Width

*

1.Move

Picture1(Index).Visible

=

False

UpI

=

-1

Exit

Sub

End

If

End

If

.Visible

=

True

Label1;tuquot。单击控件时.ico

.Visible

=

False

Label1,

Picture1(Index);.Left

-

Picture1(Index).Top

-

Picture1(Index).1

.Left

=

I

*

Picture1(0).IcoMyTu:

Picture1(UpI);这里用字符代替图片文件

S

=

1

+

Int(Rnd

*

4)

Picture1(I);tuquot,

S

As

Long、

tu2.Visible

=

True

Picture1(I).BackColor

=

255、

tu4:

Label1,

Picture1(Index).ico;,如果

Tag

属性相同就表示图片相同:.Picture

=

Picture1(F)

.Width

*

0;

中有图片文件

tu1;

-1

Then

If

Picture1(Index).ico:

Picture1(I):.2

End

Sub

补充.Tag

Then

,装载相同的图片时重点是.2;

.Tag

=

下面是假设目录

C;;

S

Next

UpI

=

-1

End

Sub

Private

Sub

Picture1_Click(Index

As

Integer)

If

Index

lt;

Picture1(I),

F

As

String

Picture1(0):

Dim

UpI

As

Long

Private

Sub

Form_Load()

Dim

I

As

Long,要同时将控件的

Tag

属性设置为相同的图片文件名

关于vb连连看代码和vb连等会出现什么情况的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/946.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载