Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7524639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:07:27+00:00 2026-05-30T03:07:27+00:00

I am building a program that randomly generates a number then this number is

  • 0

I am building a program that randomly generates a number then this number is linked to a picture, that displays in a picture box. I have one that has a text box below it, and one of the pictures is variable depending on what this text box says, so I used some if and else statements. But I get this error, ‘Else’ must be preceded by a matching ‘If’ or ‘ElseIf’. There is probably a simple solution to it that I am just not seeing, here is the code.

Private Sub Button9_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    Timer1.Start()
    Dim key As Integer
    key = (Rnd() * 3)
    Select Case key
        Case 1
            Label14.Text = "Assault"
        Case 2
            Label14.Text = "Support"
        Case 3
            Label14.Text = "Specialist"
    End Select
    If Label14.Text = "Assault" Then
        Timer1.Start()
        Dim key1 As Integer
        key1 = (Rnd() * 15)
        Select Case key1
            Case 1
                PictureBox10.Image = My.Resources.assault_1
                TextBox7.Text = "AC130"
                If TextBox14.Text = "Hardline" Then TextBox8.Text = "11"
                Else TextBox8.Text = "12"
            Case 2
                PictureBox10.Image = My.Resources.assault_2
                TextBox7.Text = "Care Package"
                If TextBox14.Text = "Hardline" Then TextBox8.Text = "3"
                Else TextBox8.Text = "4"
            Case 3
                PictureBox10.Image = My.Resources.assault_3
                TextBox7.Text = "Juggernaut"
                If TextBox14.Text = "Hardline" Then TextBox8.Text = "14"
                Else TextBox8.Text = "15"
            Case 4
                PictureBox10.Image = My.Resources.assault_4
                TextBox7.Text = "Attack Helicopter"
                If TextBox14.Text = "Hardline" Then TextBox8.Text = "6"
                Else TextBox8.Text = "7"
            Case 5
                PictureBox10.Image = My.Resources.assault_5
                TextBox7.Text = "Pave Low"
                If TextBox14.Text = "Hardline" Then TextBox8.Text = "11"
                Else TextBox8.Text = "12"
            Case 6
                PictureBox10.Image = My.Resources.assault_6
                TextBox7.Text = "IMS"
                If TextBox14.Text = "Hardline" Then TextBox8.Text = "4"
                Else TextBox8.Text = "5"
            Case 7
                PictureBox10.Image = My.Resources.assault_7
                TextBox7.Text = "Assault Drone"
                If TextBox14.Text = "Hardline" Then TextBox8.Text = "9"
                Else TextBox8.Text = "10"
            Case 8
                PictureBox10.Image = My.Resources.assault_8
                TextBox7.Text = "Strafe Run"
                If TextBox14.Text = "Hardline" Then TextBox8.Text = "8"
                Else TextBox8.Text = "9"
            Case 9
                PictureBox10.Image = My.Resources.assault_9
                TextBox7.Text = "AH-6 Overwatch"
                If TextBox14.Text = "Hardline" Then TextBox8.Text = "8"
                Else TextBox8.Text = "9"
            Case 10
                PictureBox10.Image = My.Resources.assault_10
                TextBox7.Text = "Osprey Gunner"
                If TextBox14.Text = "Hardline" Then TextBox8.Text = "16"
                Else TextBox8.Text = "15"
            Case 11
                PictureBox10.Image = My.Resources.assault_11
                TextBox7.Text = "Percision Airstrike"
                If TextBox14.Text = "Hardline" Then TextBox8.Text = "5"
                Else TextBox8.Text = "6"
            Case 12
                PictureBox10.Image = My.Resources.assault_12
                TextBox7.Text = "Predator Missile"
                If TextBox14.Text = "Hardline" Then TextBox8.Text = "4"
                Else TextBox8.Text = "5"
            Case 13
                PictureBox10.Image = My.Resources.assault_13
                TextBox7.Text = "Reaper"
                If TextBox14.Text = "Hardline" Then TextBox8.Text = "8"
                Else TextBox8.Text = "9"
            Case 14
                PictureBox10.Image = My.Resources.assault_14
                TextBox7.Text = "Sentry Gun"
                If TextBox14.Text = "Hardline" Then TextBox8.Text = "4"
               Else  TextBox8.Text = "5"
            Case 15
                PictureBox10.Image = My.Resources.assault_15
                TextBox7.Text = "Assault UAV"
                If TextBox14.Text = "Hardline" Then TextBox8.Text = "2"
                Else TextBox8.Text = "3"

        End Select
    End If
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:07:28+00:00Added an answer on May 30, 2026 at 3:07 am

    You can’t have code after THEN “AND” have an ELSE on a different line:

    You code:

    If TextBox14.Text = "Hardline" Then TextBox8.Text = "11"
      Else TextBox8.Text = "12"
    

    Fix:

    If TextBox14.Text = "Hardline" Then
      TextBox8.Text = "5"
    Else
      TextBox8.Text = "6"
    End If
    

    or:

    If TextBox14.Text = "Hardline" Then TextBox8.Text = "5" Else TextBox8.Text = "6"
    

    or place an underscore at the end:

    If TextBox14.Text = "Hardline" Then TextBox8.Text = "11" _
      Else TextBox8.Text = "12"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a C# program that unzips a file, and work on this
I'm building a program that communicates with Emacs, and one of the challenges I'm
I'm building a program that has several functions that need to read data from
I'm building a word anagram program that uses a database which contains one simple
I'm building a program that has a very basic premise. For X amount of
I am building a program that takes an input file in this format: title
I'm building a application that sends a test message to another email, the program
I have downloaded a code when I am building the program, a message window
I have an C++ program that runs on an embedded system. When the client
Hi I'm building a program that uses a signal handler shown below ... struct

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.