• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

VB V 5.0 help needed!

LeStEr

Diamond Member
Hi, for my end of the year project i have to make a Number Puzzle game where there will be a square and inside the square there will be 8 numbers and then the 9th will be blank and the person will have to move the numbers arround to make the numbers go in the right positions. I know the basics of visual basic but i have no idea where to get started. I skipped this class like 30 times this semester and im lost but then again i do have basic knowledge of VB. Im sure this would be a realativly simple program but im once again lost. It has to include arrays and some other stuff but my teacher wants an array to be included for sure. If anyone has any tips or pointers that could point me in the right direction of getting this started, it would be much appreciated.
Thanks
 
what I would do is set up an array to hold your square, probably a 5x5 2d array. as you move each object(number), update that array position with that object, checking for bounds etc.
 
Ive been trying to get a good start on this but have failed and cant get anything going. Is there any sites that could help me with this kind of thing?
 
you should have gone to class, this is an easy program.

post what you have tried and i'll try to point you in the right direction.
 
This is what i have so far:

Dim index As Integer
Dim X As Single
Dim Y As Single
Option Explicit
______________________________________________________________

Private Sub Form_DragOver(Source As Control, X As Single, Y As Single, State As Integer)

If X < 1200 Then
Source.Left = 720
ElseIf X >= 1200 And X < 1680 Then
Source.Left = 1200
Else
Source.Left = 1680
End If
Label1.Caption = X


If Y < 840 Then
Source.Top = 360
ElseIf Y >= 840 And Y < 1320 Then
Source.Top = 840
Else
Source.Top = 1320
End If
Label2.Caption = Y


End Sub


Works ok , basically i just have 8 command buttons set up in a square type shape with the bottom right hand corner open. Right now it works fine but i can still move a square from the top all the way to the bottom and put it in the emtpy square. Also the labels are nothing to do with the project, i just had them display the X and Y values so i could see what was going on while running the program.
Thanks
 
I just got done writting that app it took me an hour, it really really bad code that can be much more effeciant but i dont care its late and i havent used vb for like 6 months... if you want it PM or mail me
Smoketopia@yahoo.com

PMs are better

If anyone wants to see it ill send it your way too.
 
Hi, i just got it working so when it starts now a random number from 1 to 8 will come up on each of the buttons.

Dim Index As Integer
Dim X As Single
Dim Y As Single
Option Explicit

________________________________________________________

Private Sub Form_Activate()
Dim intnum As Integer
Dim intrandom As Integer
Dim bytAssigned As Byte
Dim source As Control
Randomize
For intnum = 0 To 7
Do
intrandom = Int(Rnd * 8)
bytAssigned = 0
If cmdNum(intrandom).Caption = &quot;&quot; Then
cmdNum(intrandom).Caption = intnum + 1
bytAssigned = 1
End If
Loop While bytAssigned = 0
Next intnum
End Sub

Private Sub Form_Dragdrop(source As Control, X As Single, Y As Single)

If X < 1200 Then
source.Left = 720
ElseIf X >= 1200 And X < 1680 Then
source.Left = 1200
Else
source.Left = 1680
End If
Label1.Caption = X


If Y < 840 Then
source.Top = 360
ElseIf Y >= 840 And Y < 1320 Then
source.Top = 840
Else
source.Top = 1320
End If
Label2.Caption = Y
End Sub
 
You will have to rewrite the CheckWin Sub that tells you if you won, because it wont work if you have different numbers in the labels, but thats easy.
 
Back
Top