show score for random image in vb

novac0

New Member
Joined
Sep 9, 2016
Messages
1
hi everyboy , im from morocco , and soory for my bad engish ,,, i want to make a simple game with 43 random images from imagelist , 43 buttons and 1 picturebox , so i want to make score displayed in textbox3 for every image in imagelist1 ,, for exemple:
Code:
if picturebox1.image= imagelist.images(0) then
textbox3.text+=13

when picturebox1.image= imagelist.images(1) then
textbox3.text+=5

when picturebox1.image= imagelist.images(3) then
textbox3.text+=40

and the same for other images

(this exemple codes is not correct)

,
so my codes
-----------
Code:
Public Class Form1

    Private _images As New List(Of Image)
    Private _unusedImages As New List(Of Image)
    Private _ran As New Random


 




    Private Function getImage() As Image
        Dim indx As Integer
        Dim rtn As Image = Nothing


        If _unusedImages.Count > 0 Then
            indx = _ran.Next(0, _unusedImages.Count)
            rtn = _unusedImages.Item(indx)
            _unusedImages.Remove(rtn)


        End If


        Return rtn




    End Function
Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'Insert code to populate _images with the images that you want displayed
        For Each img As Image In ImageList1.Images
            _images.Add(img)
        Next


        _unusedImages.Clear()
        _unusedImages.AddRange(_images)




    End Sub




    Private Sub Buttons_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click,
        Button2.Click, Button3.Click, Button4.Click, Button5.Click, Button6.Click, Button7.Click,
        Button8.Click, Button9.Click, Button10.Click, Button11.Click, Button12.Click, Button13.Click,
        Button14.Click, Button15.Click, Button16.Click, Button17.Click, Button18.Click, Button19.Click,
        Button20.Click, Button21.Click, Button22.Click, Button23.Click, Button24.Click, Button25.Click,
        Button26.Click, Button27.Click, Button28.Click, Button29.Click, Button30.Click, Button31.Click,
        Button32.Click, Button33.Click, Button34.Click, Button35.Click, Button36.Click, Button37.Click,
        Button38.Click, Button39.Click, Button40.Click, Button41.Click, Button42.Click, Button43.Click, Button44.Click
        CType(sender, Button).Visible = False




        PictureBox1.Image = getImage()




    End Sub

can someone help me pliz , thank u
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,225,551
Messages
6,185,607
Members
453,307
Latest member
addydata

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top