Public Module Program Private Function AddLong(lX As Long, lY As Long) As Long '长整数加法函数 Dim lX4 As Long Dim lY4 As Long Dim lX8 As Long Dim lY8 As Long Dim lResult As Long lX8 = lX And &H80000000 lY8 = lY And &H80000000 lX4 = lX And &H40000000 lY4 = lY And &H40000000 lResult = (lX And &H3FFFFFFF) + (lY And &H3FFFFFFF) If lX4 And lY4 Then lResult = lResult Xor &H80000000 Xor lX8 Xor lY8 ElseIf lX4 Or lY4 Then If lResult And &H40000000 Then lResult = lResult Xor &HC0000000 Xor lX8 Xor lY8 Else lResult = lResult Xor &H40000000 Xor lX8 Xor lY8 End If Else lResult = lResult Xor lX8 Xor lY8 End If AddLong = lResult End Function Private Function SubtractLong(lX As Long, lY As Long) As Long '长整数减法函数 Dim lX8 As Long Dim lY8 As Long Dim mX As Double Dim mY As Double Dim mResult As Double Dim lResult As Long Dim Bit_32 As Long Dim MAXINT_4 As Long MAXINT_4 = 2147483647 Bit_32 = 2147483648 lX8 = lX And &H80000000 lY8 = lY And &H80000000 mX = lX And &H7FFFFFFF mY = lY And &H7FFFFFFF If lX8 Then If lY8 Then mResult = mX - mY Else mX = mX + Bit_32 mResult = mX - mY End If Else If lY8 Then mY = lY mResult = mX - mY Else mResult = mX - mY End If End If If mResult < 0 Then lResult = ((Bit_32 + mResult) Or &H80000000) And &HFFFFFFFF ElseIf mResult > MAXINT_4 Then lResult = ((mResult - Bit_32) Or &H80000000) And &HFFFFFFFF Else lResult = mResult And &HFFFFFFFF End If SubtractLong = lResult End Function Public Function LeftRotateLong(lValue, lBits) As Long Dim lBits As Integer Dim var_98 As Long Dim var_88 As Long Dim var_90 As Long Dim var_92 As Integer Dim var_9C As Integer lBits = (lBits Mod &H20) var_98 = lValue If (lBits = 0) Then var_88 = var_98 LeftRotateLong = var_88 End If For var_9C = 1 To lBits: var_92 = var_9C 'Integer var_90 = (var_98 And &H40000000) var_98 = ((var_98 And &H3FFFFFFF) * 2) If CBool((var_90 And &H40000000)) Then var_98 = (var_98 Or -2147483648) End If Next var_9C 'Integer var_88 = var_98 LeftRotateLong = var_88 End Function Public Function RightRotateLong(lValue, lBits) As Long Dim var_98 As Long Dim lBits As Integer Dim var_88 As Long Dim var_90 As Long Dim var_92 As Integer Dim var_9C As Integer var_98 = lValue lBits = (lBits Mod &H20) If (lBits = 0) Then var_88 = var_98 RightRotateLong = var_88 End If For var_9C = 1 To lBits: var_92 = var_9C 'Integer var_90 = (var_98 And -2147483648) var_98 = CLng((CDbl((var_98 And &H7FFFFFFE)) / CDbl(2))) If CBool(var_90) Then var_98 = (var_98 Or &H40000000) End If Next var_9C 'Integer var_88 = var_98 RightRotateLong = var_88 End Function Public Sub Main(args() As string) Dim var_B0 As Long Dim var_B4 As Long Dim var_B8 As Long Dim var_BC As Long Dim var_110 As Integer Dim var_C0 As Integer Dim var_A8 As Integer Dim var_AA As Integer Dim var_RE As String Dim var_A4(5) As Long Console.WriteLine(SubtractLong(1640531527, -1640521527)) Console.WriteLine(AddLong(-1640531527, -1640521527)) Console.WriteLine(LeftRotateLong(-1640531527, 5)) Console.WriteLine(RightRotateLong(-1640531527, 5)) var_RE = "Testword" var_AA = 1 For var_110 = 0 To 3: var_C0 = var_110 var_A4(CLng(var_AA)) = ((var_A4(CLng(var_AA)) * &H100) + CLng((Asc(CStr(Mid(var_RE, CLng((((var_AA * 4) + 1) + 1)), 1))) Mod 256))) Next var_110 var_B4 = &H20202020 var_B8 = &H21212121 var_BC = &H22222222 var_B0 = 0 For var_C0 = 1 To &H20: var_A8 = var_C0 var_B0 = AddLong(var_B0, -1640531527) var_B4 = var_B4 Xor AddLong(AddLong(LeftRotateLong(var_B8, 4) Xor -559038737, var_B8 Xor var_B0), RightRotateLong(var_B8, 5) Xor -1161901314) var_B8 = var_B8 Xor AddLong(AddLong(LeftRotateLong(var_BC, 4) Xor -559038737, var_BC Xor var_B0), RightRotateLong(var_BC, 5) Xor -1161901314) var_BC = var_BC Xor AddLong(AddLong(LeftRotateLong(var_B4, 4) Xor -559038737, var_B4 Xor var_B0), RightRotateLong(var_B4, 5) Xor -1161901314) Next var_C0 var_B0 = -957401312 For var_C0 = 1 To &H20: var_A8 = var_C0 var_B0 = SubtractLong(var_B0, -1640531527) var_BC = var_BC Xor AddLong(AddLong(LeftRotateLong(var_B4, 4) Xor -559038737, var_B4 Xor var_B0), RightRotateLong(var_B4, 5) Xor -1161901314) var_B8 = var_B8 Xor AddLong(AddLong(LeftRotateLong(var_BC, 4) Xor -559038737, var_BC Xor var_B0), RightRotateLong(var_BC, 5) Xor -1161901314) var_B4 = var_B4 Xor AddLong(AddLong(LeftRotateLong(var_B8, 4) Xor -559038737, var_B8 Xor var_B0), RightRotateLong(var_B8, 5) Xor -1161901314) Next var_C0 Console.WriteLine(var_B4) Console.WriteLine(var_B8) Console.WriteLine(var_BC) 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