Imports System Public Module Module1 Public Sub Main() Dim Category [0:15] As String Dim ItemCode [0:15] As String Dim Description [0:15] As String Dim Price [0:15] As Decimal Dim TotalMoney As Decimal Dim i As Integer Dim ChosenDevice , ChosenSIM ,ChosenCase , ChosenCharger , ChosenCharger2 As Integer Dim MobilePurchased [0:4] As Integer Dim TabletPurchased [0:4] As Integer Dim ChoiceNO As Integer Category()={"phone","phone","phone","phone","phone","phone","Tablet","Tablet" ,"Tablet","Tablet","SIM Card","SIM Card","case","case","charger","charger"} ItemCode()={"BPCM","BPSH","RPSS","RPLL","YPLS","YPLL","RTMS","RTLM" ,"YTLM","YTLL","SMNO","SMPG","CSST","CSLX","CGCR","CGHM"} Description()={"compact","clamshell","Robophone-5-inch screen and 64 GB memory","Robophone -6- inch screen and 256 GB memory", "phone standard -6- inch screen and 64 GB memory","phone Deluxe -6- inch screen and 256 GB memory", "RoboTab -8- ich screen and 64 GB memory","RoboTab -10- inch screen and 128 GB memory", "TabStandard -10- inch screen and 128 GB memory","Tab Deluxe -10- inch screen and 256 GB memory ","SIM Free (no SIMcard purchased)", "Pay As You GO (SIMcard purchased)","Standard","Luxury","Car","Home"} Price()={29.99,49.99,199.99,499.99,549.99,649.99,149.99,299.99,499.99,599.99,9.99,0.00,50.00,19.99,15.99} For i= 0 To 9 console.WriteLine(i,"-", Category(i) , ItemCode(i) , Description(i) , "$" , Price(i) ) Next i Console.writeline("please select a number") console.WriteLine("1-phone") console.WriteLine("2-Tablet") ChoiceNo= console.ReadLine() If ChoiceNo=1 Then Do console.WriteLine("please select a phone number from list (0-5)" ) console.writeline("please select a SIM number from list (10,11)") console.WriteLine("1- SIM Free") console.WriteLine("2- SIM / Pay As You Go") ChosenDevice =console.ReadLine() ChosenSIM = console.ReadLine() Loop Until < ChosenDevice>=0 AND ChosenDevice<=5 > MobilePurchased(0)= ChosenDevice If ChosenSIM =1 Then MobilePurchased(1)=10 Else If ChosenSIM =2 Then MobilePurchased(1)=11 Else console.writeline("please re-enter SIM number from list") console.writeline("1-SIM Free") console.writeline("2- SIM/ Pay As You Go") End If End If Else Do console.writeline("please select a tablet number from list (6-9)") ChosenDevice = console.Readline() Loop Until < ChosenDevice >=6 AND ChosenDevice<=9 > TabletPurchased(0)= ChosenDevice TabletPurchased(1)= -1 console.writeline("please select a case number from list (12,13)") console.writeline("1- standard") console.writeline("2- luxury") ChosenCase = console.Readline If ChoiceNo=1 AND ChosenCase=1 Then MobilePurchased(2)=12 Else MobilePurchased(2)=13 End If If ChoiceNo=2 AND ChosenCase=1Then TabletPurchased(2)=12 Else If ChoiceNo=2 AND ChosenCase=2 Then TabletPurchased(2)=13 Else console.writeline("please re-enter case number from list ") console.writeline("1-Standard") console.writeline("2-Luxury") End If End If console.writeline("please select a charger number from list (14,15)") cosole.writeline("1-Both") console.writeline("2-None") console.writeline("3-Only one") ChosenCharger=console.Readline() IF ChoiceNo=1 AND ChosenCharger=1 Then MobilePurchased(3)=14 MobilePurchased(4)=15 Else If ChoiceN0=1 AND ChosenCharger=2 Then MobilePurchased(3)=-1 MobilePurchased(4)=-1 Else If ChoiceNo=1 AND ChosenCharger=3 Then console.writeline("please select type of charger from list (14,15)") console.writeline("1-Home Charger") console.writeline("2-Car Charger") ChosenCharger2 = console.Readline() If ChosenCharger2=1 Then MobilePurchased(3)=-1 MobilePurchased(4)=15 Else MobilePurchased(3)=14 MobilePurchased(4)=-1 End If End If If ChoiceNo=2 AND ChosenCharger=1 Then TabletPurchased(3)=14 TabletPurchased(4)=15 Else If ChoiceNo=2 AND ChosenCharger=2 Then TabletPurchased(3)=-1 TabletPurchased(4)=-1 Else If ChoiceNo=2 AND ChosenCharger=3 Then console.writeline("please select type of charger from list ") console.writeline("1-Home Charger") console.writeline("2-Car Charger") ChosenCharger2= console.Readline() If ChosenCharger2=1 Then TabletPurchased(3)=-1 TabletPurchased(4)=15 Else TabletPurchased(3)=14 TabletPurchased(4)=-1 End If Else console.writeline("please re-enter charger number from list ") console.writeline("1-Both") console.writeline("2-None") console.writeline("3-Only one") End If End If End If TotalMoney=0 If ChoiceNo=1 Then For i = 0 To 4 console.writeline(Category(MobilePurchased(i)) , ItemCode(MobilePurchased(i)) , Description(MobilePurchased(i)) ,"$" ,Price(MobilePurchased(i)) If MobilePurchased(i) <> -1 Then TotalMoney = TotalMoney + Price(MobilePurchased(i)) End If Next i console.writeline("Total money paid = ","$","TotalMoney") Else For i = 0 To 4 console.writeline(Category(TabletPurchased(i)), ItemCode(TabletPurchased(i)), Description(TabletPurchased(i)), "$", Price(TabletPurchased(i))) If TabletPurchased(i) <> -1 Then TotalMoney = TotalMoney + Price(TabletPurchased(i)) End If Next i console.writeline("Total money paid = " ,"$", TotalMoney) End If Module Module2 Sub Main () Dim OverallMoney As Decimal Dim DeviceCounter As Integer Do console.writeline("Do you want to buy an additional device (phone or tablet)") console.writeline("1- Yes ") console.writeline("2- No ") ChosenDevice2 = console.Readline() If ChosenDevice2 = 1 Then Do Module task 1() DeviceCounter=DeviceCounter+1 OverallMoney=OverallMoney+TotalMoney Else If ChosenDevice2 = 2 Then OverallMoney=OverallMoney+TotalMoney Else console.writeline("please re-enter your choice") console.writeline("1-Yes")s console.writeline("2-No") End If End If Loop Until < ChosenDevice2=2 > console.writeline("overall money paid = $", OverallMoneny) End sub End Module Module Module3 Sub Main () Dim OverallReduction As Decimal const Reduction As Decimal Do Do Module task 2() DeviceCounter=DeviceCounter+1 If DeviceCounter > 1 AND ChoiceNo=1 Then Reduction=Price(MobilePurchased(o))- (Price(MobilePurchased(0))*0.9) TotalMoney=TotalMoney-Reduction console.writeline("Total money paid after discount = $" , TotalMoney) OverallReduction = OverallReduction + Reduction Else If DeviceCounter > 1 AND ChoiceNo =2 Then Reduction = Price(TabletPurchased(0))- (Price(TabletPurchased(0))*0.9) TotalMoney=TotalMoney-Reduction console.writeline("Total money paid after discount = $",TotalMoney) OverallReduction = OverallReduction + Reduction Else console.writeline("Not eligible for discount") End If End If Loop Until <ChosenDevice=2> console.writeline("Overall money paid=$", OverallMoney) console.writeline("Overall reduction=$" , OverallReduction) End Sub End Module
Write, Run & Share VB.net code online using OneCompiler's VB.net online compiler for free. It's one of the robust, feature-rich online compilers for VB.net language, running on the latest version 16. Getting started with the OneCompiler's VB.net compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as VB.net
. OneCompiler also has reference programs, where you can look for the sample code to get started with.
OneCompiler's VB.net online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample VB.net program which takes name as input and prints hello message with your name.
Public Module Program
Public Sub Main(args() As string)
Dim name as String = Console.ReadLine() ' Reading input from STDIN
Console.WriteLine("Hello " & name) ' Writing output to STDOUT
End Sub
End Module
Visual Basic is a event driven programming language by Microsoft, first released in the year 1991.
Variable is a name given to the storage area in order to identify them in our programs.
Simple syntax of Variable declaration is as follows
Dim variableName [ As [ New ] dataType ] [ = initializer ]
variableName = value
If condition-expression Then
'code
End If
If(conditional-expression)Then
'code if the conditional-expression is true
Else
'code if the conditional-expression is false
End If
If(conditional-expression)Then
'code if the above conditional-expression is true
Else If(conditional-expression) Then
'code if the above conditional-expression is true
Else
'code if the above conditional-expression is false
End If
If(conditional-expression)Then
'code if the above conditional-expression is true
If(conditional-expression)Then
'code if the above conditional-expression is true
End If
End If
Select [ Case ] expression
[ Case expressionlist
'code ]
[ Case Else
'code ]
End Select
For counter [ As datatype ] = begin To end [ Step step ]
'code
[ Continue For ]
'code
[ Exit For ]
'code
Next [ counter ]
For Each element [ As datatype ] In group
'code
[ Continue For ]
'code
[ Exit For ]
'code
Next [ element ]
While conditional-expression
'Code
[ Continue While ]
'Code
[ Exit While ]
'Code
End While
Do { While | Until } conditional-expression
'Code
[ Continue Do ]
'Code
[ Exit Do ]
'Code
Loop
Do
'Code
[ Continue Do ]
'Code
[ Exit Do ]
'Code
Loop { While | Until } conditional-expression
Procedure is a sub-routine which contains set of statements. Usually Procedures are written when multiple calls are required to same set of statements which increases re-usuability and modularity.
Procedures are of two types.
Functions return a value when they are called.
[accessModifiers] Function functionName [(parameterList)] As returnType
'code
End Function
Sub-procedures are similar to functions but they don't return any value.
Sub ProcedureName (parameterList)
'Code
End Sub