Posting this again because I was given a completely wrong answer but I appreciate anyone who can try to help me with this.
Unzip and open the Turner Solution\Turner Solution.sln file. Set the codeTextBox's MaxLength property to 1. The codeTextBox should accept only the numbers 1, 2, 3, and 4 and the Backspace key; code the appropriate event procedure. Code the displayButton_Click procedure to display the appropriate image in the displayPictureBox. The appropriate image is based on the code entered by the user. Display the house1PictureBox's image when the code is 1, and so on. If the codeTextBox is empty, set the display PictureBox's Image property to the keyword Nothing. Size the form to hide the four picture boxes, and then lock the controls. Save the solution and then start and test the application. Close and submit this week's entire project folder into a single zip file.
I need this code in Visual Basic please I basically need one text box and one button coded. I need Visual Basic code for the text box known above to only accept numbers 1-4 and backspace key press. I then need code for the display button so it displays the image of whatever number is inputted inside of the code text box. Like 1 should show house1PictureBox, 2 should show house2PictureBox, 3 should show house3PictureBox, and 4 should show house4PictureBox, and no input show show nothing. I'll explain what everything is because I unfortunately cannot show it. The application has codeTextBox, displayButton, exitButton(already coded), displayPictureBox, house1PictureBox, house2PictureBox, house3PictureBox, and house4PictureBox. Again I really need this in Visual Basic here's the code already given to me. I really would appreciate it if an expert can help thank you!
Option Explicit On
Option Strict On
Option Infer Off
Public Class MainForm
Private Sub exitButton_Click(sender As Object, e As EventArgs)
Handles exitButton.Click
Me.Close()
End Sub
End Class
Try below coding:
Dim img As Image =
Image.FromFile("C:\Users\Pranesh\Pictures\11599264.jpg")
house1PictureBox.Image = img
house2PictureBox.Image = img
house3PictureBox.Image = img
house4PictureBox = img
house1PictureBox.Visible = False
house2PictureBox.Visible = False
house3PictureBox.Visible = False
house4PictureBox.Visible = False
Private Sub button1_Click(ByVal sender As Object, ByVal e As
EventArgs)
If codeTextBox.Text = "1" Then
house1PictureBox.Visible = True
ElseIf codeTextBox.Text = "2" Then
house2PictureBox.Visible = True
ElseIf codeTextBox.Text = "3" Then
house3PictureBox.Visible = True
ElseIf codeTextBox.Text = "4" Then
house4PictureBox.Visible = True
Else
MessageBox.Show("Invalid number")
End If
End Sub
Result:
Waiting for your comments
Get Answers For Free
Most questions answered within 1 hours.