Question

I really need some help fixing a code error in Visual Basic I was wondering if...

I really need some help fixing a code error in Visual Basic I was wondering if anyone could help fix the error that I'm about to provide in bold thanks so much! I'll also tell what the error is.

Public Class MainForm
Private Sub exitButton_Click(sender As Object, e As EventArgs) Handles exitButton.Click
Me.Close()
End Sub

Dim img As Image = Image.FromFile("C:\Users\Pranesh\Pictures\11599264.jpg")
house1PictureBox.Image = img
house2PictureBox.Image = img
house3PictureBox.Image = img
house4PictureBox.Image = img


house1PictureBox.Visible = False
house2PictureBox.Visible = False
house3PictureBox.Visible = False
house4PictureBox.Visible = False

Private Sub displayButton_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
End Class

The error is declaration expected. If anyone who's an expert on Visual Basic knows how to fix it I would appreciate it thank you!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Below is the correct code.

Public Class Form1
'Form Load Event
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim img As Image = Image.FromFile("C:\Users\Pranesh\Pictures\11599264.jpg")
house1PictureBox.Image = img
house2PictureBox.Image = img
house3PictureBox.Image = img
house4PictureBox.Image = img
house1PictureBox.Visible = False
house2PictureBox.Visible = False
house3PictureBox.Visible = False
house4PictureBox.Visible = False
End Sub
'Exit button click
Private Sub exitButton_Click(sender As Object, e As EventArgs) Handles exitButton.Click
Me.Close()
End Sub
'display Button click

Private Sub displayButton_Click(sender As Object, e As EventArgs) Handles displayButton.Click
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
End Class

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
I really need some help fixing a code error in Visual Basic I was wondering if...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help with this problem in Visual Basic 2012: Write a program that allows the...

    I need help with this problem in Visual Basic 2012: Write a program that allows the user to specify two numbers and then adds, subtracts, multiplies, or divides them when the user clicks on the appropriate button. The output should give the type of arithmetic performed and the result. Whenever one of the numbers in an input text box is changed, the output text box should be cleared. Also, if the number 0 is entered into the second text box,...

  • so im trying to make a grade program and idk what im doing wrong actually if...

    so im trying to make a grade program and idk what im doing wrong actually if someone can help? (heres the lines of code i have so far if its wrong let me know how to fix them Option Strict On Option Explicit On Public Class Form1 Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click Dim lblscore1 As Double Dim lblscore2 As Double Dim lblscore3 As Double lblscore1 = CDbl(Txtscore1.Text) lblscore2 = CDbl(Txtscore2.Text) lblscore3 = CDbl(Txtscore3.Text) lblaverage =...

  • The Murach's Visual Basic 2015 Book And Visual Studio Exercise 7-2 Enhance the Invoice Total application...

    The Murach's Visual Basic 2015 Book And Visual Studio Exercise 7-2 Enhance the Invoice Total application If you did exercise 6-1 in the last chapter, this exercise asks you to add data validation and exception handling to it. 1. Copy the Invoice Total application from your C:\VB 2015\Chapter 06 directory to your Chapter 07 directory. This should be your solution to exercise 6-1 of the last chapter. 2. If your application has both a Sub procedure and a Function procedure...

  • Public Class Form1     Private Sub CompleteReport_Click(sender As Object, e As EventArgs) Handles CompleteReport.Click         Dim...

    Public Class Form1     Private Sub CompleteReport_Click(sender As Object, e As EventArgs) Handles CompleteReport.Click         Dim room As Double 'Assigns room as double         Dim rate As Double 'Assigns rate as double         Dim room2 As Double 'Assigns room as double         Dim overallRate As Double 'Assigns overall as double         Dim a As Integer 'Assign a as an integer         For a = 1 To 8 'Assign a as an 1 to 8 for all 8 floors             With...

  • I am new to programming (2 weeks of playing with it) I have written code for...

    I am new to programming (2 weeks of playing with it) I have written code for a timer in Visual Studio 2013. I am wondering if someone can show me how to write code/what the code would look like in a MODULE1.vb. I was thinking that for this timer I could create MsgBox using a DO UNTIL LOOP that would pop up every 20 seconds that says "hurry up!" until 1 minute has passed. As I said I am just...

  • Project 2 – Memory Match Game Purpose This Windows Classic Desktop application plays a simple matching game. The game si...

    Project 2 – Memory Match Game Purpose This Windows Classic Desktop application plays a simple matching game. The game simulates a card game where the cards a placed face down and the player flips over pairs of cards in an attempt to find matching cards.   Program Procedure Display a 4x4 grid of “face down” cards. Assign the letters A through H randomly to the cards in pairs. Allow the user to click on a card to “flip” it over and...

  • Project 10-1 Convert lengths In this assignment, you’ll add code to a form that converts the valu...

    Project 10-1 Convert lengths In this assignment, you’ll add code to a form that converts the value the user enters based on the selected conversion type. The application should handle the following conversions: From To Conversion Miles - Kilometers: 1 mile = 1.6093 kilometers Kilometers - Miles: 1 kilometer = 0.6214 miles Feet - Meters: 1 foot = 0.3048 meters Meters - Feet: 1 meter = 3.2808 feet Inches - Centimeters: 1 inch = 2.54 centimeters Centimeters - Inches: 1...

  • WITH THIS CODE, ADD TO THE EXIT BUTTON THAT ALLOWS THE USER TO SEE UPON EXITING,...

    WITH THIS CODE, ADD TO THE EXIT BUTTON THAT ALLOWS THE USER TO SEE UPON EXITING, HOW MANY QUESTIONS THEY GOT RIGHT AND WRONG. Public Class Form1 Dim r As Random = New Random Dim no1, no2 As Integer Private Sub rdbAdd_CheckedChanged(sender As Object, e As EventArgs) Handles rdbAdd.CheckedChanged txtAnswer.Clear() txtAnswer.BackColor = Color.White no1 = randomInt() no2 = randomInt() lblOperation.Text = "+" txtNumber1.Text = no1.ToString() txtNumber2.Text = no2.ToString() End Sub Public Function randomInt() As Integer Return r.Next(20, 120) End Function...

  • Visual Basic: Create an application that simulates a tic tac toe game. The form uses 9...

    Visual Basic: Create an application that simulates a tic tac toe game. The form uses 9 large labels to display the x's and o's. The application should use a two dimensional integer array to simulate the game board in memory. When the user clicks the "New Game" button the application should step throguh the array storing a random number of 0 to 1 in each element. The numer 0 represent the letter o and the number 1 reprsents the letter...

  • I’m attempting to create the functioning GUI (bottom photo) from the coding in the first photo....

    I’m attempting to create the functioning GUI (bottom photo) from the coding in the first photo. I’m unclear as to what I’m missing to complete the code. Thank you a Homework 8 similar to Exercise 16 8.pdf (page 1 of 2) Public Class Formi Dim answer As Integer Sub Random() Dim random As New Random() answer randon.Next (1, 1ee) End Sub Private Sub Formi Load(ByVal sender As System.Object, Byval e As System. EventArgs) Handles MyBase. Load Random() End Sub Private...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT