Post: Vb Coding - help?
02-12-2011, 09:05 PM #1
GoonerSam
Who’s Jim Erased?
(adsbygoogle = window.adsbygoogle || []).push({}); I'm a noob coder before you rage at me :embarrassed:

I just need help with how to make a check that makes sure a user cannot put a letter instead of a number?


Module Module1

Sub Main()
Console.WriteLine("Welcome, to the ISBN-code checker, v1.141.")
Console.WriteLine("Please Enter the first digit of your of your ISBN number")
Dim UserInput1 As Integer
Dim UserInput2 As Integer
Dim UserInput3 As Integer
Dim UserInput4 As Integer
Dim UserInput5 As Integer
Dim UserInput6 As Integer
Dim UserInput7 As Integer
Dim UserInput8 As Integer
Dim UserInput9 As Integer
Dim UserInput10 As Integer
UserInput1 = Console.ReadLine
Console.WriteLine("Enter the second digit")
UserInput2 = Console.ReadLine
Console.WriteLine("Enter the third digit")
UserInput3 = Console.ReadLine
Console.WriteLine("Enter the fourth digit")
UserInput4 = Console.ReadLine
Console.WriteLine("Enter the fifth digit")
UserInput5 = Console.ReadLine
Console.WriteLine("Enter the sixth digit")
UserInput6 = Console.ReadLine
Console.WriteLine("Enter the seventh digit")
UserInput7 = Console.ReadLine
Console.WriteLine("Enter the eigth digit")
UserInput8 = Console.ReadLine
Console.WriteLine("Enter ninth digit")
UserInput9 = Console.ReadLine
Console.WriteLine("Enter the tenth digit")
UserInput10 = Console.ReadLine
Console.WriteLine("------------------------")
Console.WriteLine(Math.Round((UserInput1 * 11) + (UserInput2 * 10) + (UserInput3 * 9) + (UserInput4 * 8 ) + (UserInput5 * 7) + (UserInput6 * 6) + (UserInput7 * 5) + (UserInput8 * 4) + (UserInput9 * 3) + (UserInput10 * 2)))
Console.ReadLine()

Dim iRemainder As Integer
iRemainder = ((UserInput1 * 11) + (UserInput2 * 10) + (UserInput3 * 9) + (UserInput4 * 8 ) + (UserInput5 * 7) + (UserInput6 * 6) + (UserInput7 * 5) + (UserInput8 * 4) + (UserInput9 * 3) + (UserInput10 * 2) Mod 11)
Console.WriteLine("Your REMAINDER is " & iRemainder Mod 11)
Console.WriteLine("To see your ISBN and CHECK DIGIT, press the enter key")
Console.ReadLine()

Console.WriteLine("Your ISBN code - INCLUDING the check digit is: " & UserInput1 & UserInput2 & UserInput3 & UserInput4 & UserInput5 * UserInput6 & UserInput7 & UserInput8 & UserInput9 & UserInput10 & (11 - (iRemainder Mod 11)))
Console.WriteLine("and your check digit is: " & (11 - (iRemainder Mod 11)))

Console.ReadLine()




End Sub

End Module


I just need a variable check... :hug:
02-12-2011, 09:47 PM #2
Originally posted by GoonerSam View Post
I'm a noob coder before you rage at me :embarrassed:

I just need help with how to make a check that makes sure a user cannot put a letter instead of a number?


Module Module1

Sub Main()
Console.WriteLine("Welcome, to the ISBN-code checker, v1.141.")
Console.WriteLine("Please Enter the first digit of your of your ISBN number")
Dim UserInput1 As Integer
Dim UserInput2 As Integer
Dim UserInput3 As Integer
Dim UserInput4 As Integer
Dim UserInput5 As Integer
Dim UserInput6 As Integer
Dim UserInput7 As Integer
Dim UserInput8 As Integer
Dim UserInput9 As Integer
Dim UserInput10 As Integer
UserInput1 = Console.ReadLine
Console.WriteLine("Enter the second digit")
UserInput2 = Console.ReadLine
Console.WriteLine("Enter the third digit")
UserInput3 = Console.ReadLine
Console.WriteLine("Enter the fourth digit")
UserInput4 = Console.ReadLine
Console.WriteLine("Enter the fifth digit")
UserInput5 = Console.ReadLine
Console.WriteLine("Enter the sixth digit")
UserInput6 = Console.ReadLine
Console.WriteLine("Enter the seventh digit")
UserInput7 = Console.ReadLine
Console.WriteLine("Enter the eigth digit")
UserInput8 = Console.ReadLine
Console.WriteLine("Enter ninth digit")
UserInput9 = Console.ReadLine
Console.WriteLine("Enter the tenth digit")
UserInput10 = Console.ReadLine
Console.WriteLine("------------------------")
Console.WriteLine(Math.Round((UserInput1 * 11) + (UserInput2 * 10) + (UserInput3 * 9) + (UserInput4 * 8 ) + (UserInput5 * 7) + (UserInput6 * 6) + (UserInput7 * 5) + (UserInput8 * 4) + (UserInput9 * 3) + (UserInput10 * 2)))
Console.ReadLine()

Dim iRemainder As Integer
iRemainder = ((UserInput1 * 11) + (UserInput2 * 10) + (UserInput3 * 9) + (UserInput4 * 8 ) + (UserInput5 * 7) + (UserInput6 * 6) + (UserInput7 * 5) + (UserInput8 * 4) + (UserInput9 * 3) + (UserInput10 * 2) Mod 11)
Console.WriteLine("Your REMAINDER is " & iRemainder Mod 11)
Console.WriteLine("To see your ISBN and CHECK DIGIT, press the enter key")
Console.ReadLine()

Console.WriteLine("Your ISBN code - INCLUDING the check digit is: " & UserInput1 & UserInput2 & UserInput3 & UserInput4 & UserInput5 * UserInput6 & UserInput7 & UserInput8 & UserInput9 & UserInput10 & (11 - (iRemainder Mod 11)))
Console.WriteLine("and your check digit is: " & (11 - (iRemainder Mod 11)))

Console.ReadLine()




End Sub

End Module


I just need a variable check... :hug:



If Not IsNumeric(userinput1) then
userinput1 = ""
Else
End If
02-12-2011, 09:57 PM #3
GoonerSam
Who’s Jim Erased?
Originally posted by MoBaTeY View Post
If Not IsNumeric(userinput1) then
userinput1 = ""
Else
End If




Would i need to declare "IsNumeric" as something - and also, this would make it one huge case yes ?
02-12-2011, 10:05 PM #4
Originally posted by GoonerSam View Post
Would i need to declare "IsNumeric" as something - and also, this would make it one huge case yes ?


You dont have to declare IsNumeric, its already predefined. Also if you want to do it for all of them, then just add it into the code.

The following user thanked MoBaTeY for this useful post:

GoonerSam
02-12-2011, 10:33 PM #5
GoonerSam
Who’s Jim Erased?
Originally posted by MoBaTeY View Post
You dont have to declare IsNumeric, its already predefined. Also if you want to do it for all of them, then just add it into the code.


oh alright, thanks man Smile

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo