help in placing multiple pictureboxes to different location by using keypress event

ljpv14

Active member
Joined
Nov 28, 2011
Messages
44
Programming Experience
3-5
I have this code. credits to jmchiney. My goal is when I press a certain key, the picturebox corresponding to that key should be moved to a certain location. Exactly like in the text twist game.

I have a code running and doing what I want but It is only applicable for single letter. For example the word alabama. all letters without duplicates are placed properly but for letter a, only one letter a is being accepted and moved. that goes for all letters. I know there is something wrong with my code. I need help badly!

Here is the code:
Dim pb As New PictureBox
Select Case (e.KeyChar)


Case CChar(letterPicbox1.Tag)
pb = letterPicbox1
Case CChar(letterPicbox2.Tag)
pb = letterPicbox2
Case CChar(letterPicbox3.Tag)
pb = letterPicbox3
Case CChar(letterPicbox4.Tag)
pb = letterPicbox4
Case CChar(letterPicbox5.Tag)
pb = letterPicbox5
Case CChar(letterPicbox6.Tag)
pb = letterPicbox6
Case CChar(letterPicbox7.Tag)
pb = letterPicbox7
End Select


If pb IsNot Nothing Then
Select Case (currentWordLen)
Case 5
If counter1 = 0 Then
pb.Location = New Point(145, 100)
ElseIf counter1 = 1 Then
pb.Location = New Point(225, 100)
ElseIf counter1 = 2 Then
pb.Location = New Point(305, 100)
ElseIf counter1 = 3 Then
pb.Location = New Point(385, 100)
ElseIf counter1 = 4 Then
pb.Location = New Point(465, 100)
End If
counter1 += 1
Case 6
If counter1 = 0 Then
pb.Location = New Point(110, 100)
ElseIf counter1 = 1 Then
pb.Location = New Point(190, 100)
ElseIf counter1 = 2 Then
pb.Location = New Point(270, 100)
ElseIf counter1 = 3 Then
pb.Location = New Point(350, 100)
ElseIf counter1 = 4 Then
pb.Location = New Point(430, 100)
ElseIf counter1 = 5 Then
pb.Location = New Point(510, 100)
End If
counter1 += 1
Case 7
If counter1 = 0 Then
pb.Location = New Point(80, 100)
ElseIf counter1 = 1 Then
pb.Location = New Point(160, 100)
ElseIf counter1 = 2 Then
pb.Location = New Point(240, 100)
ElseIf counter1 = 3 Then
pb.Location = New Point(320, 100)
ElseIf counter1 = 4 Then
pb.Location = New Point(400, 100)
ElseIf counter1 = 5 Then
pb.Location = New Point(480, 100)
ElseIf counter1 = 6 Then
pb.Location = New Point(560, 100)
End If
counter1 += 1
End Select
Else
End If

Another one. when a certain letter is already placed to the location I set and once I press again the same letter, the location changes. What I want is when I already gave pictureboxA a location and then I press "a" which correspond to pictureboxA again it should be stationary and check if there are other letter "a" in my pictureboxes and move the next detected letter "a" to the next position. Like i said. just like text twist game. If anyone can help me. I'm really going to be VERY thankful! :)
 
Duplicate threads really aren't going to get you any brownie points here.
 
Back
Top