samedi 9 janvier 2016

How to Loop through a If condition untill the user enter a required value, in Visual Basic

  Console.WriteLine("Please Enter the Number of Units")
    Dim uNITS As Integer = Console.ReadLine()

    If (uNITS <= 50) Then
        uNITS = uNITS * 20
    ElseIf (uNITS <= 100) Then
        uNITS = uNITS * 25
    Else
        uNITS = uNITS * 35
    End If
    Console.WriteLine(uNITS)

    Dim fINALvALUE As Integer
    Dim uSERvALUE As SByte
    Console.WriteLine("Please, type 1 if the connection is a commercial type . Type 2 if the connection is a Resident type. Type 3 if the connection is a Special type")
    uSERvALUE = Console.ReadLine()

    If uSERvALUE = 1 Then
        Console.WriteLine("You Chose: Commercial Type")
        fINALvALUE = uNITS * (115 / 100)
    ElseIf uSERvALUE = 2
        Console.WriteLine("You Chose: Resident Type")
        fINALvALUE = uNITS * (105 / 100)
    ElseIf uSERvALUE = 3
        Console.WriteLine("You chose: Special Type")
        fINALvALUE = uNITS * (102 / 100)
    Else
        Console.WriteLine("Sorry we coudn't recognize your response please re-enter the value")
        uSERvALUE = Nothing


    End If

`Here is a screenshot of my code

Please tell me how to repeat the if condition in the screenshot in the link. In the else line I have displayed to the user to re-enter the value. Therefore I need to repeat the if condition until the value is 1 or 2 or 3.

Aucun commentaire:

Enregistrer un commentaire