Funktion aufrufen

  • VB.NET

Es gibt 4 Antworten in diesem Thema. Der letzte Beitrag () ist von Samus Aran.

    Funktion aufrufen

    Huhu ihr :)

    Für euch einfach, für mich schwer:

    Wie kann ich eine Funktion aufrufen ?
    "Life isn't about winning the race. Life is about finishing the race and how many people we can help finish the race." ~Marc Mero

    Nun bin ich also auch soweit: Keine VB-Fragen per PM! Es gibt hier ein Forum, verdammt!
    z.B.: wenn die Funktion so aussieht:

    VB.NET-Quellcode

    1. Private Function Funktionsname(ByVal test as string) As Boolean
    2. If test = "blubb" then
    3. return true
    4. else
    5. return false
    6. End Function

    Dann kannst du es z.B.: so aufrufen:

    VB.NET-Quellcode

    1. If Funktionsname("blubb") = True then
    2. 'blubb
    3. End If
    Die Funktion ist diese hier, zum kompiliren von Code:

    VB.NET-Quellcode

    1. IO.File.WriteAllText(tmpfile, code)
    2. If IO.File.Exists(outpath) Then IO.File.Delete(outpath)
    3. Dim p As New Process With {.StartInfo = New ProcessStartInfo With {.Arguments = " /t:exe """ & tmpfile & """", .WindowStyle = ProcessWindowStyle.Hidden, .FileName = IO.Path.Combine(New IO.FileInfo(Application.ExecutablePath).Directory.Root.FullName, "WINDOWS\Microsoft.NET\Framework\v3.5\vbc.exe")}}
    4. p.Start()
    5. p.WaitForExit()
    6. Return IO.File.Exists(outpath)
    7. End Function
    "Life isn't about winning the race. Life is about finishing the race and how many people we can help finish the race." ~Marc Mero

    Nun bin ich also auch soweit: Keine VB-Fragen per PM! Es gibt hier ein Forum, verdammt!
    Kommt drauf an, welchen Typ die Funktion zurückgibt (Function... As DeinTyp).
    Siehe gugis Beispiel, dort gibt die Funktion nen Boolean zurück (As Boolean, Return True/False), also kannst du die Funktion wie einen Boolean nutzen.
    (Form1.Enabled = Funktionsname, nur als Beispiel)