2 Replies - 245 Views - Last Post: 06 November 2017 - 12:27 AM Rate Topic: -----

#1 PLOstyle  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 25-May 15

Radio Button in a If Statement with different ranges in numbers

Posted 05 November 2017 - 11:48 PM

I have two radio buttons, but each button has different ranges of numbers....In both Radio buttons the first range works but uses the same (plus+5)and (multiply by 30)formula in the others. Can I get some advice on what I'm doing wrong please!!!!!!

 

Option Explicit On
Option Infer Off
Option Strict Off




Public Class MainForm



    Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub



    Private Sub calcButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calcButton.Click

        Dim range As Decimal
        Dim total As Decimal
        Integer.TryParse(unitTextBox.Text, unit)

        If firstRadioButton.Checked = True And range >= 1 <= 4 Then
            order = range + 5
        ElseIf firstRadioButton.Checked = True And range >= 5 Then
            order = range + 10
        End If


        If secondRadioButton.Checked = True And range >= 1 <= 3 Then
            total = range * 30
        ElseIf secondRadioButton.Checked = True And range >= 4 <= 8 Then
            total = range * 15
        ElseIf secondRadioButton.Checked = True And range >= 9 Then
            total = range * 10
        End If

        totalTextBox.Text = Convert.ToString(total)
        totalTextBox.Text = total.ToString()
End Sub
    Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click
        Me.Close()
    End Sub
End Class



Is This A Good Question/Topic? 0
  • +

Replies To: Radio Button in a If Statement with different ranges in numbers

#2 andrewsw  Icon User is online

  • the case is sol-ved
  • member icon

Reputation: 6376
  • View blog
  • Posts: 25,761
  • Joined: 12-December 12

Re: Radio Button in a If Statement with different ranges in numbers

Posted 06 November 2017 - 12:05 AM

These range >= 1 <= 4 are not valid/working expressions (it is disappointing if VB lets the code run). You need to test both terms separately using AND.

It also looks like you never assign range a value.
Was This Post Helpful? 1
  • +
  • -

#3 PLOstyle  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 25-May 15

Re: Radio Button in a If Statement with different ranges in numbers

Posted 06 November 2017 - 12:27 AM

View Postandrewsw, on 06 November 2017 - 12:05 AM, said:

These range >= 1 <= 4 are not valid/working expressions (it is disappointing if VB lets the code run). You need to test both terms separately using AND.

It also looks like you never assign range a value.

Thank You.....
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1