Ebben a részben az én saját dolgaimat teszem föl. Főként VB órai munkák.
Dim a, b, c As Integer
Sub main() a = CInt(InputBox("a=")) b = CInt(InputBox("b=")) c = CInt(InputBox("c=")) If c / a < 0 Then MsgBox ("Az egyik gyök negatív, a másik pozitív!") ElseIf -(b / a) < 0 Then MsgBox ("Mindkét gyök negatív!") Else: MsgBox ("Minden gyök pozitív!") End If
End Sub
Option Explicit
Dim A As Double
Dim B As Double
Sub main()
A = InputBox("Szám A:", _"A szám megadása")
B = InputBox("Szám B:", _"B szám megadása")
If A Mod B = 0 Then
MsgBox "B Oszt=ja A-nak:"
ElseIf B Mod A = 0 Then
MsgBox "A Oszt=ja B-nak:"
Else
MsgBox "Nem osztható: "
End If
End Sub
VBgyak 3
Option Explicit Dim w(9) As Integer, I As Integer, S As String, Z As Integer
Sub main() Randomize S = "A generált számok" + Chr(13) For I = 0 To 9 w(I) = Int(50 * Rnd + 1) S = S + CStr(w(I)) + " " Next MsgBox S Z = 0 For I = 1 To 9 Step 2 Z = Z + w(I) Next MsgBox "Paratlan indexu : " + CStr(Z / 5)
Z = 0 For I = 0 To 8 Step 2 Z = Z + w(I) Next MsgBox "Paros indexu : " + CStr(Z / 5)
End Sub
Sub Main()
Dim A As Integer
A = 2
MsgBox "A=" + CStr(A)
Call első(A)
MsgBox "Első után=" + CStr(A)
Call második(A)
MsgBox "M.utan" + CStr(A)
End Sub
Sub első(ByVal X As Integer)
X = X + 2
MsgBox "X=" + CStr(X)
End Sub
Sub második(ByRef y As Integer)
y = y ^ 2
MsgBox "Y=" + CStr(y)
End Sub
Dim x As Double
Dim y As Double
Sub Main()
x = 2
y = Parabola(x)
MsgBox "Y=" + CStr(y)
End Sub
Function Parabola(ByVal z As Double) As Double
Parabola = z ^ 2 - 2 * z + 1
End Function
Option Explicit Dim A As Double, B As Double Dim M As Double, SZ As Double
Sub main() A = InputBox("A szam:") B = InputBox("B szam:") M = Mertani(A, B) Call Szamtani(A, B, SZ) MsgBox "Mertani: " + CStr(M) + _ " Szamtani: " + CStr(SZ) End Sub
Function Mertani(ByVal A As Double, _ ByVal B As Double) _ As Double Mertani = (A * B) ^ (1 / 2) End Function
Sub Szamtani(ByVal A As Double, _ ByVal B As Double, _ ByRef SZ As Double) SZ = (A + B) / 2 End Sub
HFFFFFFF
Option Explicit Dim A As Integer
Sub main() Call Beolvas(A) If A <= 0 Then Else MsgBox "Negatív számot adtáll meg!" End End If
End Sub
Sub Beolvas(ByRef A As Integer) A=InputBox ("Add meg az A számot") End Sub
Option Explicit Dim Ta As Double, Tm As Double Dim Ter As Double, Fel As Double
Sub main() Call Beolvas(Tm) Call Beolvas(Ta) Ter = Terfogat(Ta, Tm) Call Felszin(Ta, Tm, Fel) MsgBox "Terfogat: " + CStr(Ter) + _ " Felszin: " + CStr(Fel) End Sub
Function Terfogat(ByVal A As Double, _ ByVal M As Double) _ As Double Terfogat = A * A * M End Function
Sub Felszin(ByVal A As Double, _ ByVal M As Double, _ ByRef Vfel As Double) Vfel = A * A + 4 * A * M End Sub
Sub Beolvas(ByRef Ta As Double) Do Ta = InputBox("Ta") If Ta < 0 Then MsgBox "nem pozitiv szam" End If Loop Until Ta > 0 End Sub |