0% found this document useful (0 votes)
11 views3 pages

Imports System

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

Imports System

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Imports System

Module Program
Sub Main(args As String())

Dim inp As String = "-TEMP-"


While presenceCheck(inp) = 0
Console.WriteLine("Enter a string: ")
inp = Console.ReadLine()
End While

inp = "-TEMP-"
While lengthCheck(inp) = 0
Console.WriteLine("Enter a string which has more then 7 characters:
")
inp = Console.ReadLine()
End While

Dim diffInp
While typeCheck(diffInp) = 0
Console.WriteLine("Enter an integer: ")
diffInp = Console.ReadLine
End While

Dim numInp As Integer = 12093


While rangeCheck(numInp) = 0
Console.WriteLine("Enter a number between 0 and 10: ")
numInp = Console.ReadLine()
End While

inp = "-TEMP-"
While letterRangeCheck(inp) = 0
Console.WriteLine("Enter a letter between A and M: ")
inp = Console.ReadLine()
End While

End Sub

Function presenceCheck(inp)

If inp = "-TEMP-" Then


Return 0

ElseIf Len(inp) <> 0 Then


Console.WriteLine("Well done!")
Return 1
Else
Console.WriteLine("Try again. Enter something.")
Return 0
End If

End Function

Function lengthCheck(inp)

If inp = "-TEMP-" Then


Return 0

ElseIf Len(inp) > 7 Then


Console.WriteLine("Well done!")
Return 1
Else
Console.WriteLine("Try again. Enter something.")
Return 0
End If

End Function

Function typeCheck(diffInp)
If diffInp = Nothing Or diffInp Mod 1 <> 0 Then
Return 0
Else
Try
Dim newInp As Integer = diffInp / 2
Console.WriteLine("Well done")

Return 1
Catch ex As Exception
Console.WriteLine("Try again - input an integer")
Return 0
End Try
End If

End Function

Function rangeCheck(numInp)
If numInp = 12093 Then
Return 0

ElseIf numInp > -1 And numInp < 11 Then


Console.WriteLine("Well done!")
Return 1
Else
Console.WriteLine("Try again. Enter a number between 0 and 10
inclusive.")
Return 0
End If
End Function

Function letterRangeCheck(letterInp)

If letterInp = "-TEMP-" Then


Return 0
Else
Try
Dim letter As Char = letterInp.ToString.ToLower()
Dim asciiletter = Asc(letter)
If asciiletter > 96 And asciiletter < 110 Then
Console.WriteLine("Well done!")
Return 1
Else
Console.WriteLine("Try to enter a letter between A and M")
Return 0
End If
Catch ex As Exception
Console.WriteLine("Enter a letter")
Return 0
End Try
End If

End Function
End Module

You might also like