VB.NET Questions Answers-conditional statements (PartIII)

VB.NET conditional statements (PartIII)

1. Rewrite the following VB.NET code using on switch statement:
If(ch='a' Or ch='A') then
ElseIf(ch='e' Or ch='E') then
ElseIf(ch='i' Or ch='I') then
ElseIf(ch='o' Or ch='O') then
ElseIf(ch='u' Or ch='U') then
Else : Console.WriteLine("No vowel letter")
End If Check answer 2. What is the output from the following VB.NET program?

Module Module1
     Sub Main()
       Dim m As Integer
       Console.Write("Enter month from 1 to 12:")
       Select case m{
          Case 1: Console.WriteLine("January")
          Case 2: Console.WriteLine("Frebruary")
          Case 3: Console.WriteLine("March")
          Case 4: Console.WriteLine("April")
          Case 5: Console.WriteLine("May")
          Case 6: Console.WriteLine("June")
          Case 7: Console.WriteLine("July")
          Case 8: Console.WriteLine("August")
          Case 9: Console.WriteLine("September")
          Case 10: Console.WriteLine("October")
          Case 11: Console.WriteLine("November")
          Case 12: Console.WriteLine("December")
          Case Else : Console.WriteLine("Invalid month")
        End Select
    End Sub
End Module Check answer 3. What are the input and output from the following VB.NET program?

Module Module1
   Sub Main()
      Dim num, rnum, count As Integer
      count = 1
       Console.Write("Enter your number:") ' ask for a guess number
       num = Integer.Parse(Console.ReadLine())
       Dim x As New Random()

        rnum = 1 + x.Next(6) 'generate random number from 1 to 6

        If (num = rnum) Then
             Console.WriteLine("Correct!") 'correct guess
             count += 1
             Console.WriteLine("Incorrect!") 'incorrect guess then

             If (count <= 3) Then GoTo ag 'you can try 3 times

      End If

    End Sub
End Module

Check answer


This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.