Log in

View Full Version : VB Help


The Ninja
May 11th, 2011, 05:46 PM
Updated Question/s at bottom, SCROLL DOWN

I need help writing a code that will randomly execute one of four commands every 2 seconds in VB.
These commands are:
Label1.Top + 100
Label1.Top - 0
Label1.Left + 100
Label1.Left - 100

I also need a bit of code that stops the label from going off the edge of the window. The window size is 300x500 (L*H)

Any help given will be rewarded with some rep.

Joshh97
May 11th, 2011, 05:53 PM
All I can say is create a PHP String like captcha to randomly select the commands, if possible implement them in to a db

The Ninja
May 11th, 2011, 06:05 PM
All I can say is create a PHP String like captcha to randomly select the commands, if possible implement them in to a db

I'm sorry, but I didn't understand a word of that.

TheMatrix
May 12th, 2011, 12:15 AM
I need help writing a code that will randomly execute one of four commands every 2 seconds in VB.
These commands are:
Label1.Top + 100
Label1.Top - 0
Label1.Left + 100
Label1.Left - 100

I also need a bit of code that stops the label from going off the edge of the window. The window size is 300x500 (L*H)

Any help given will be rewarded with some rep.
Do you mean VB as in:
VB - Microsoft Web Scripting language
or
VB - VisualBasic
or
VB - vBulletin

I'm sorry, but I didn't understand a word of that.
I think that what he means is to create a captchca to select commands :confused: and put those commands into a database to save and execute them later.
But I don't know :/

The Ninja
May 12th, 2011, 12:54 AM
VB as in visual basic.

I've pretty much got it figured out except I need to declare Var1 and 2 as random numbers from 1-5. If you'd like to know what the fuck im doing with this scroll down.


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Start1:
If Var1 = 1 Then
GoTo Up1
End If

If Var1 = 2 Then
GoTo Dn1
End If

If Var1 = 3 Then
GoTo Rt1
End If

If Var1 = 4 Then
GoTo Lt1
End If

If Var1 = 5 Then
GoTo No1
End If
Up1:
PictureBox2.Top = PictureBox2.Top - 100 'up'
GoTo Start2
Dn1:
PictureBox2.Top = PictureBox2.Top + 100 'Down'
GoTo Start2
Rt1:
PictureBox2.Left = PictureBox2.Left + 100 'Right'
GoTo Start2
Lt1:
PictureBox2.Left = PictureBox2.Left - 100 'Left'
GoTo Start2
No1:
PictureBox2.Left = PictureBox2.Left + 0 'No movement'
GoTo Start2

Start2:
If Var2 = 1 Then
GoTo Up2
End If

If Var2 = 2 Then
GoTo Dn2
End If

If Var2 = 3 Then
GoTo Rt2
End If

If Var2 = 4 Then
GoTo Lt2
End If

If Var2 = 5 Then
GoTo No2
End If
Up2:
PictureBox5.Top = PictureBox5.Top - 100 'up'
GoTo Start1
Dn2:
PictureBox5.Top = PictureBox5.Top + 100 'Down'
GoTo Start1
Rt2:
PictureBox5.Left = PictureBox5.Left + 100 'Right'
GoTo Start1
Lt2:
PictureBox5.Left = PictureBox5.Left - 100 'Left'
GoTo Start1
No2:
PictureBox5.Left = PictureBox5.Left + 0 'No movement'
GoTo Start1
End Sub


Ok so basically I'm trying to create a some what AI (Artificially Intelligent) program. There are two squares. one red, one blue. The game is a lot like capture the flag except the player doesn't have to bring the flag back. So if you happen to hit the enemy while on your side of the map you win and vice versa. Now these squares move around a 3x4 unit area. They take turns moving one unit per second. There movements are completely random. So how is it AI then. Well if they win they repeat the same set of moves where as the loser tries a different set. This continues until the winner loses. So what I want to do is make an archive of every move either player has made so that they never repeat themselves. Once all possible outcomes have been recorded it checks each one to see which one it won the most with. It uses this set of moves until it loses in which case it uses the second best. Eventually I might integrate the ability for the other computer to check and prepare itself for what the opponent has chosen. It may even come to the point where the pieces are moving in real time. I might create a larger map and more computers etc.

TheMatrix
May 12th, 2011, 11:53 PM
ummmmmmm.....okay!

i don't know visual basic. sorry.