Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

VISUAL BASIC HELP please !! block if without end if

  • 17-02-2011 03:10PM
    #1
    Registered Users, Registered Users 2 Posts: 255 ✭✭


    Can someone please help me everytime I try to run this program block if without end if appears... I dont know what to I am fairly bew to this so help would be much appreciated thanks.. Also it highlights Public Sub Updatelabel()

    Public Sub UpdateLabel()
    Dim Info
    ' Sound
    If chkSound.Value = 1 Then
    Info = "Sound: ON"
    Else
    Info = "Sound: OFF"
    End If
    ' Mouse
    If chkMouse.Value = 1 Then
    Info = Info + Chr(13) + "Mouse: ON"
    Else
    Info = Info + Chr(13) + "Mouse: OFF"
    End If
    ' Colors
    If chkColors.Value = 1 Then
    Info = Info = Chr(13) + "Colors: ON"
    Info = Info = Chr(13) + "Colors: OFF"
    End If
    ' Level
    If optLevel1.Value = True Then
    Info = Info + Chr(13) + "Level:1"
    End If
    If optLevel2.Value = True Then
    Info = Info + Chr(13) + "Level:2"
    If optLevel3.Value = True Then
    Info = Info + Chr(13) + "Level:3"
    End If
    lblChoice.Caption = Info
    End Sub


Comments

  • Registered Users, Registered Users 2 Posts: 2,857 ✭✭✭Duckjob


    Can someone please help me everytime I try to run this program block if without end if appears... I dont know what to I am fairly bew to this so help would be much appreciated thanks.. Also it highlights Public Sub Updatelabel()

    Public Sub UpdateLabel()
    Dim Info
    ' Sound
    If chkSound.Value = 1 Then
    Info = "Sound: ON"
    Else
    Info = "Sound: OFF"
    End If
    ' Mouse
    If chkMouse.Value = 1 Then
    Info = Info + Chr(13) + "Mouse: ON"
    Else
    Info = Info + Chr(13) + "Mouse: OFF"
    End If
    ' Colors
    If chkColors.Value = 1 Then
    Info = Info = Chr(13) + "Colors: ON"
    Info = Info = Chr(13) + "Colors: OFF"
    End If
    ' Level
    If optLevel1.Value = True Then
    Info = Info + Chr(13) + "Level:1"
    End If
    If optLevel2.Value = True Then
    Info = Info + Chr(13) + "Level:2"
    End If
    If optLevel3.Value = True Then
    Info = Info + Chr(13) + "Level:3"
    End If
    lblChoice.Caption = Info
    End Sub


    Adding the highlighted line should do the trick.


  • Registered Users, Registered Users 2 Posts: 255 ✭✭SellingJuan


    Now it says expected end sub .... Thanks for your help

    ' All variables Must be declared.
    Option Explicit
    Private Sub chkColors_Click()
    UpdateLabel
    End Sub
    Private Sub chkMouse_Click()
    UpdateLabel
    End Sub

    Private Sub chkSound_Click()
    UpdateLabel
    End Sub

    Private Sub cmdExit_Click()
    End
    End Sub
    Private Sub optLevel1_Click()
    UpdateLabel
    End Sub

    Private Sub optLevel2_Click()
    UpdateLabel
    End Sub

    Private Sub optLevel3_Click()
    UpdateLabel
    End Sub
    Public Sub UpdateLabel()
    Dim Info
    ' Sound
    If chkSound.Value = 1 Then
    Info = "Sound: ON"
    Else
    Info = "Sound: OFF"
    End If
    ' Mouse
    If chkMouse.Value = 1 Then
    Info = Info + Chr(13) + "Mouse: ON"
    Else
    Info = Info + Chr(13) + "Mouse: OFF"
    End If
    ' Colors
    If chkColors.Value = 1 Then
    Info = Info = Chr(13) + "Colors: ON"
    Info = Info = Chr(13) + "Colors: OFF"
    End If
    ' Level
    If optLevel1.Value = True Then
    Info = Info + Chr(13) + "Level:1"
    End If
    If optLevel2.Value = True Then
    Info = Info + Chr(13) + "Level:2"
    End If
    If optLevel3.Value = True Then
    Info = Info + Chr(13) + "Level:3"
    End If


  • Registered Users, Registered Users 2 Posts: 255 ✭✭SellingJuan


    Actually its ok I figured it out forgot to end sub and lbl choice thanks alot for your help tho it was much appreciated :)


Advertisement