Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27033

VS 2010 newb help: simple console addittion code, need help with variable addittion

$
0
0
Ok so i wrote this simple code for me to add several birth dates together, via console user input. You enter the first day digit, second day digit, first month digit, second month digit, & 1, 2, 3rd & 4th year digit. It adds them together. If it's equal to 11, 22, 33, or 44 it writes it out in this format * NUMBER *. Otherwise it just shows the total number on one line..i.e. 27

So what i need help doing is....adding the resulting 2 digits together (if they aren't already 11,22,33 or 44) & showing the result. I.E. if the result is 27, it would add 2 & 7...so it should write out 9 instead of 27. Or if it the result is 29...it should then write out * 11 * as per the IF..THEN.

So here is my current code. I'm using it to learn basic vb math/input operations. I'm starting all over from the beginning with vb & trying to learn the right way. So I would really appreciate someone simply re-writing my code, so i can see exactly how you do it via simple console. Thanks so much!

Code:

    Sub Main()
        Do
            Console.WriteLine("First birth month number?")
            Dim mm1 As Integer = Console.ReadLine()
            Console.WriteLine("Second birth month number?")
            Dim mm2 As Integer = Console.ReadLine
            Console.WriteLine("First birth day number?")
            Dim dd1 As Integer = Console.ReadLine
            Console.WriteLine("Second birth day number?")
            Dim dd2 As Integer = Console.ReadLine
            Console.WriteLine("First birth year number?")
            Dim yy1 As Integer = Console.ReadLine
            Console.WriteLine("Second birth year number?")
            Dim yy2 As Integer = Console.ReadLine
            Console.WriteLine("Third birth year number?")
            Dim yy3 As Integer = Console.ReadLine
            Console.WriteLine("And the last birth year number is..")
            Dim yy4 As Integer = Console.ReadLine
            Dim Digitz As Integer
            Digitz = mm1 + mm2 + dd1 + dd2 + yy1 + yy2 + yy3 + yy4
            Console.WriteLine()
            If Digitz = 11 Then
                Console.WriteLine("* 11 *")
            End If
            If Digitz = 22 Then
                Console.WriteLine("* 22 *")
            End If
            If Digitz = 33 Then
                Console.WriteLine("* 33 *")
            End If
            If Digitz = 44 Then
                Console.WriteLine("* 44 *")
            End If
            Console.WriteLine(Digitz)
        Loop
    End Sub


Viewing all articles
Browse latest Browse all 27033

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>