I don't know what equation vb will recognise for my code. to work. The user chooses weather to enter a decimal number or binary. It will then use an equation to convert that number. I have started the decimal but then got stuck, with what equation to use.
This is the code:
Module Module1
Sub Main()
Dim userchoice As String
Dim numberchoice, numchoice, newnumber As Integer
Console.WriteLine("Please choose weather to convert 1) decimal to Binary or 2)Binary to decimal.")
userchoice = Console.ReadLine()
If userchoice = 1 Then
Console.WriteLine("You are converting from a Decimal - Binary")
Console.WriteLine("Please enter the number,")
numberchoice = Console.ReadLine()
End If
If numberchoice > 128 Then
Console.WriteLine("1")
newnumber = numberchoice - 128
End If
If newnumber > 64 Then
Console.WriteLine("1")
newnumber = newnumber - 64
End If
If numberchoice > 32 Then
Console.WriteLine("1")
newnumber = newnumber - 32
End If
If numberchoice > 16 Then
Console.WriteLine("1")
newnumber = newnumber - 16
End If
If numberchoice > 8 Then
Console.WriteLine("1")
newnumber = newnumber - 8
End If
If numberchoice > 4 Then
Console.WriteLine("1")
newnumber = newnumber - 4
End If
If numberchoice > 2 Then
Console.WriteLine("1")
newnumber = newnumber - 2
End If
If numberchoice > 1 Then
Console.WriteLine("1")
newnumber = newnumber - 1
End If
Console.ReadLine()
If userchoice = 2 Then
Console.WriteLine("You're converting from Binary - Decimal")
Console.WriteLine("Please enter the binary number,")
numchoice = Console.ReadLine()
End If
End Sub
End Module