Module VBModule Sub Main() dim NUM() As Integer redim Preserve NUM(100) dim K As Integer = 0 While K <= 100 NUM(K) = K * K K = K + 1 End While Console.WriteLine(NUM(3) + NUM(4)) End Sub End Module
Module VBModule Sub LesOne() 'Значение переменных A, B, C равны между собой' Dim intA, intB, intC As Integer intA = intB = intC End Sub Sub LesTwo() 'Переменная А (тип Single) содержит целое число' Dim sngA As Single Dim intB As Integer sngA = 5 'если переменная задана точно 'условие на целое число intB = (sngA mod 1) = 0 'отбрасывание дробной части при ее наличии sngA = sngA\1 End Sub Sub LesThree() 'Переменная X делится без остатка на Y или на Z (все переменные целочисленные)' Dim intX, intY, intZ As Integer ((sngX mod intY) = 0) AND ((sngX mod intZ) = 0) End Sub Sub LesFour() 'Дата в переменной D (тип Date) относится к весне 2005 года Dim dtmD As Date Dim dtmA, dtmB As Date dtmD = 4/15/2005 'задана точно 'определена в промежутке dtmA = 01/03/2005 dtmB = 01/06/2005 If dtmA<=dtmD<dtmB Then MsgBox(dtmD & "относится к весне 2005") else MsgBox(dtmD & "ERROR: дата не относится к весне 2005 года") End If End Sub End Module
Module VBModule Dim arrays(5) as string Sub Main() Console.Writeline("Leo") For i As Integer = 0 to 4 arrays(i) = Console.Readline Next i For j As Integer = 0 to 4 Console.Writeline(arrays(j)) Next Console.Readline() End Sub End Module
Module MyFunc Function MinFunc(ByVal n1 As Integer, ByVal n2 As Integer) AS Integer Dim Result As Integer If (n1 < n2) Then Result = n1 Else Result=n2 End if End Function Sub Main () Dim a, b, c As Integer a = 30 b = 20 c = MinFunc(a,b) Console.WriteLine ("The min number is :{0}", c) Console.ReadLine() End sub End module
Module VBModule Sub Main() 'Console.WriteLine("Hello, world!") 'dim X As Integer = 20 'dim Y As Boolean = TRUE 'dim Z As Boolean = TRUE dim X As Integer = 30 dim Y As Boolean = FALSE dim Z As Boolean = FALSE 'dim X As Integer = 40 'dim Y As Boolean = FALSE 'dim Z As Boolean = FALSE 'dim X As Integer = 50 'dim Y As Boolean = FALSE 'dim Z As Boolean = TRUE If NOT(X > 30 OR (Y AND Z)) Then Console.WriteLine("***") End If End Sub End Module
Module variablesNdataypes Sub Main() Dim num1,num2,num3 As Integer Dim average As Decimal Console.write("Enter your first number: ") num1 = console.readline Console.write("Enter your second number: ") num2 = console.readline Console.write("Enter your third number: ") num3 = console.readline sum= num1 + num2 + num3 average = sum/3 Console.Writeline("sum is: " & sum) Console.Writeline("Average is: " & average) Console.readline() End Sub End Module
Module VBModule Sub Main() Dim num1,num2 as String num1 = InputBox("enter first number") num2 = InputBox("enter second number") Dim x as new Complex(num1) Dim y as new Complex(num2) Dim a As Complex = x + y Console.writeLine(a.print()) a = x-y Console.writeLine(a.print()) a = x*y Console.writeLine(a.print()) a = x/y Console.writeLine(a.print()) End Sub Class Complex Dim r,c as Double public sub new(rr as Double,cc as Double) r = rr c = cc End sub public sub new(num as String) if num.Contains("+j") then r = num.Split(new String() { "+j" }, StringSplitOptions.None)(0) c = num.Split(new String() { "+j" }, StringSplitOptions.None)(1) else r = num.Split(new String() { "-j" }, StringSplitOptions.None)(0) c = -1 * num.Split(new String() { "-j" }, StringSplitOptions.None)(1) end if End sub public function conjugate() return New Complex(r,-1*c) End function Public Function print() As String Return Me.r & IF(c >= 0,"+","-")& "j" & System.Math.Abs(Me.c) End Function Public Shared Operator +(ByVal n1 As Complex, ByVal n2 As Complex) As Complex Return New Complex(n1.r + n2.r, n1.c + n2.c) End Operator Public Shared Operator -(ByVal n1 As Complex, ByVal n2 As Complex) As Complex Return New Complex(n1.r - n2.r, n1.c - n2.c) End Operator Public Shared Operator *(ByVal n1 As Complex, ByVal n2 As Complex) As Complex Return New Complex(n1.r * n2.r - n1.c * n2.c, n1.r * n2.c + n1.c * n2.r) End Operator Public Shared Operator /(ByVal n1 As Complex, ByVal n2 As Complex) As Complex Dim t as Complex t = n1 * n2.conjugate() Return New Complex(t.r/ (n2.c * n2.c + n2.r * n2.r), t.c / (n2.c * n2.c + n2.r * n2.r)) End Operator End Class End Module
Module VBModule Sub Main() Dim number1, number2, sum As Integer console.write("Please enter in a number: ") number1 = Console.Readline Console.Write("Please enter in another number: ") Number2 = Consloe.readline sum = Number1 + Number2 Console.writeline(number1 & " + " & Number2 & " = " & sum) Console.Read() End Sub End Module
Module VBModule Sub Main() Dim z as integer = 10 Dim y as integer = 20 Dim x as integer = 30 Dim w as integer = 40 Call Addition (z,y) Call Subtraction (z,y) Call Multiplycation (x,w) Call Division (w,y) Call Maxnumber (z,y,x,w) Call Minnumber (z,y,x,w) End Sub Sub Addition (ByVal a as integer, ByVal b as integer) Dim n as integer n = a + b Console.Writeline(n) End sub Sub Subtraction (ByVal a as integer, ByVal b as integer) Dim m as integer m = b - a Console.Writeline(m) End sub Sub Multiplycation (ByVal a as integer, ByVal b as integer) Dim k as integer k = a * b Console.Writeline(k) End sub Sub Division (ByVal a as integer, ByVal b as integer) Dim g as integer g = a / b Console.Writeline(g) End sub Sub Maxnumber (ByVal a as integer, ByVal b as integer, ByVal c as integer, ByVal d as integer) Dim h as integer If a > b and a > c and a > d then h = a Elseif b > a and b > c and b > d then h = b Elseif c > a and c > b and c > d then h = c Elseif d > a and d > b and d > c then h = d Console.Writeline(h) End if End sub Sub Minnumber (ByVal a as integer, ByVal b as integer, ByVal c as integer, ByVal d as integer) Dim i as integer If b > a and c > a and d > a then i = a Elseif a > b and c > b and d > b then i = b Elseif a > c and b > c and d > c then i = c Elseif a > d and b > d and c > d then i = d Console.Writeline(i) End if End sub End Module
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more