Public Module Program
Public Function ToArabicLetter(ByVal givenNumber As Double) As String
Dim FinalOutput, Number, NumberCurrency, Fractions, FractionsCurrency As String
Dim Tafkeet = " فقط لا غير"
Dim WholeNumber() As String = Split(givenNumber, ".")
NumberCurrency = NumberAsCurrency(WholeNumber(0))
FinalOutput = NumberCurrency
If WholeNumber.Length >= 2 Then
If WholeNumber(1).Length.Equals(1) Then
WholeNumber(1) = WholeNumber(1) + "0"
ElseIf WholeNumber(1).Length > 2 Then
WholeNumber(1) = WholeNumber(1).Substring(0, 3)
End If
FractionsCurrency = FractionAsCurrency(WholeNumber(1))
FinalOutput = FinalOutput + " و" + FractionsCurrency
End If
If FinalOutput <> Nothing And FinalOutput <> "" Then
FinalOutput = FinalOutput + Tafkeet
End If
ToArabicLetter = FinalOutput
End Function
Public Function SFormatNumber(ByVal X As Double) As String
Dim Letter1, Letter2, Letter3, Letter4, Letter5, Letter6 As String
Dim c As String = Format(Math.Floor(X), "000000000000")
Dim C1 As Double = Val(Mid(c, 12, 1))
Select Case C1
Case Is = 1 : Letter1 = "واحد"
Case Is = 2 : Letter1 = "اثنان"
Case Is = 3 : Letter1 = "ثلاثة"
Case Is = 4 : Letter1 = "اربعة"
Case Is = 5 : Letter1 = "خمسة"
Case Is = 6 : Letter1 = "ستة"
Case Is = 7 : Letter1 = "سبعة"
Case Is = 8 : Letter1 = "ثمانية"
Case Is = 9 : Letter1 = "تسعة"
End Select
Dim C2 As Double = Val(Mid(c, 11, 1))
Select Case C2
Case Is = 1 : Letter2 = "عشر"
Case Is = 2 : Letter2 = "عشرون"
Case Is = 3 : Letter2 = "ثلاثون"
Case Is = 4 : Letter2 = "اربعون"
Case Is = 5 : Letter2 = "خمسون"
Case Is = 6 : Letter2 = "ستون"
Case Is = 7 : Letter2 = "سبعون"
Case Is = 8 : Letter2 = "ثمانون"
Case Is = 9 : Letter2 = "تسعون"
End Select
If Letter1 <> "" And C2 > 1 Then Letter2 = Letter1 + " و" + Letter2
If Letter2 = "" Or Letter2 Is Nothing Then
Letter2 = Letter1
End If
If C1 = 0 And C2 = 1 Then Letter2 = Letter2 + "ة"
If C1 = 1 And C2 = 1 Then Letter2 = "احدى عشر"
If C1 = 2 And C2 = 1 Then Letter2 = "اثنى عشر"
If C1 > 2 And C2 = 1 Then Letter2 = Letter1 + " " + Letter2
Dim C3 As Double = Val(Mid(c, 10, 1))
Select Case C3
Case Is = 1 : Letter3 = "مائة"
Case Is = 2 : Letter3 = "مائتان"
Case Is > 2 : Letter3 = Microsoft.VisualBasic.Left(SFormatNumber(C3), Len(SFormatNumber(C3)) - 1) + "مائة"
End Select
If Letter3 <> "" And Letter2 <> "" Then Letter3 = Letter3 + " و" + Letter2
If Letter3 = "" Then Letter3 = Letter2
Dim C4 As Double = Val(Mid(c, 7, 3))
Select Case C4
Case Is = 1 : Letter4 = "الف"
Case Is = 2 : Letter4 = "الفان"
Case 3 To 10 : Letter4 = SFormatNumber(C4) + " آلاف"
Case Is > 10 : Letter4 = SFormatNumber(C4) + " الف"
End Select
If Letter4 <> "" And Letter3 <> "" Then Letter4 = Letter4 + " و" + Letter3
If Letter4 = "" Then Letter4 = Letter3
Dim C5 As Double = Val(Mid(c, 4, 3))
Select Case C5
Case Is = 1 : Letter5 = "مليون"
Case Is = 2 : Letter5 = "مليونان"
Case 3 To 10 : Letter5 = SFormatNumber(C5) + " ملايين"
Case Is > 10 : Letter5 = SFormatNumber(C5) + " مليون"
End Select
If Letter5 <> "" And Letter4 <> "" Then Letter5 = Letter5 + " و" + Letter4
If Letter5 = "" Then Letter5 = Letter4
Dim C6 As Double = Val(Mid(c, 1, 3))
Select Case C6
Case Is = 1 : Letter6 = "مليار"
Case Is = 2 : Letter6 = "ملياران"
Case Is > 2 : Letter6 = SFormatNumber(C6) + " مليار"
End Select
If Letter6 <> "" And Letter5 <> "" Then Letter6 = Letter6 + " و" + Letter5
If Letter6 = "" Then Letter6 = Letter5
SFormatNumber = Letter6
End Function
Public Function NumberAsCurrency(ByVal givenNumber As Double) As String
Dim Number, Currency As String
Number = SFormatNumber(givenNumber)
If Number <> "" And Number <> Nothing And givenNumber <= 2 Then
If Number.StartsWith("واحد") Then
Number = Number.Substring(4)
ElseIf Number.StartsWith("اثنان") Then
Number = Number.Substring(5)
End If
End If
Select Case CDbl(givenNumber)
Case Is = Nothing : Currency = ""
Case Is = 2 : Currency = " ريال عماني"
Case 3 To 10 : Currency = " ريال عماني"
Case Else : Currency = "ريال عماني"
End Select
NumberAsCurrency = Number + " " + Currency
End Function
Public Function FractionAsCurrency(ByVal givenNumber As Double) As String
Dim Fractions, Currency As String
Fractions = SFormatNumber(givenNumber)
If Fractions <> "" And Fractions <> Nothing And givenNumber <= 2 Then
If Fractions.StartsWith("واحد") Then
Fractions = Fractions.Substring(4)
ElseIf Fractions.StartsWith("اثنان") Then
Fractions = Fractions.Substring(5)
End If
End If
Select Case CDbl(givenNumber)
Case Is = Nothing : Currency = ""
Case Is = 2 : Currency = " بيزة"
Case 3 To 10 : Currency = " بيزة"
Case Else : Currency = " بيزة"
End Select
FractionAsCurrency = Fractions + " " + Currency
End Function
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