untypisierte datatable an funktion übergeben?

  • VB.NET
  • .NET (FX) 4.0

Es gibt 23 Antworten in diesem Thema. Der letzte Beitrag () ist von Rattenfänger.

    untypisierte datatable an funktion übergeben?

    Hallo,

    ich habe ca. 20 datatables die zur Laufzeit in meinem MDIparent erstellt werden. Hintergrund anzahl sowie Bezeichnung der tables kann sich bei jedem programmstart ändern.
    Jetzt möchte ich eine bestimmte datatable an eine Function in einer anderen klasse übergeben.

    die Funktion ist wie folgt:

    VB.NET-Quellcode

    1. Public Function test(byval tabm1 as datatable, byval tab2 as datatable) as boolean
    2. ' hier der zu bearbeitende code'
    3. end function


    leider funktioniert das net!

    welche Möglichkeiten gibt es noch ein untypisierte table weiterzugeben.
    Dieser Coder ruft die function ab

    VB.NET-Quellcode

    1. If long1.longtrade1(tabellem15, tabellem60) = True Then ' hier bricht er immer ab, keine message kein gar stackowerflow !?
    2. LLS = True
    3. buysell = "B"
    4. anzeige = "Longtrade_M15_1"
    5. GoTo order
    6. End If


    VB.NET-Quellcode

    1. Option Strict On
    2. Friend Class Longtrade
    3. Inherits HystoryForm
    4. Dim kurs As KursFunktionen
    5. Dim DMI As DMIFunktionen
    6. Dim RSI As RSIFFunktionen
    7. Dim EMA As EMAFunktionen
    8. Public Function longtrade1(ByVal tabelm15 As DataTable, ByVal tabelm60 As DataTable) As Boolean
    9. Dim ergebniss As Boolean = False
    10. If EMA.EMAzwischen(tabelm15, 2.5, 10, 5, "Short") = True And EMA.EMAsinkt(tabelm15, tabelm15.Rows.Count - 1, 5, "Short", 1.0, 0.2) _
    11. And EMA.EMAsinkt(tabelm60, tabelm60.Rows.Count - 1, 10, "Short", 1.0, 0.2) = True Then
    12. If DMI.DMIgrößer(tabelm15, "DMIM", 25.0, 10) = True And DMI.DMIkleiner(tabelm15, "DMIP", 15, 10) = True _
    13. And DMI.DMIMsinkt(tabelm15, tabelm15.Rows.Count - 1, 5, 5, 0.2) = True Then
    14. ergebniss = True
    15. End If
    16. End If
    17. Return ergebniss
    18. End Function
    19. End Class



    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Rattenfänger“ ()

    Das erste snippet ist gar keine Methode - kannst du das iwie gestalten, dass man Zusammenhänge besser erfassen kann?

    wo kommt etwa dieses long-Dingens her, und was fürn Datentyp hat das?

    (und es beschleicht mich die Vermutung, dass da aus einem Modul in ein Form gegrabscht wird, womöglich in Zusammenhang mit MultiThreading)
    Nein ist ne Form, hier die ganze klasse! Wenn dieser Code ausgeführt wird läuft eine andere Klasse, die auch auf die tables zugreifen muss, aber auch nur lesen.
    Bis jetzt hat alles super geklappt, jedoch habe ich denn irre langen code in verschiedene Klassen verteilt und durch Funktionen ausgetauscht. Und seitdem funktioniert es nicht mehr.

    VB.NET-Quellcode

    1. Option Strict On
    2. Imports fxcore2
    3. Imports System.Threading
    4. Public Class Form5
    5. Dim einstellung As New AllgemeineEinstellungen
    6. Dim long1 As New Longtrade
    7. Dim Short1 As New Shorttrade
    8. Public datagrid4(0, 0) As Object
    9. Public gridtrue As Boolean
    10. Delegate Sub DelegateUpdatePriceInfo(ByVal Innstrument As String, ByVal bid As Double, ByVal ask As Double, ByVal offerID As String, ByVal pipcost As Double)
    11. Delegate Sub DelegateUpdateTrades2(ByVal TradeID As String, ByVal OpenOrderID As String, ByVal UsedMargin As Double, ByVal OpenRate As Double, ByVal Amount As Integer, ByVal Limit As Double, ByVal Stoploss As Double, ByVal OpenTime As Date, ByVal GrossPL As Double, ByVal BuySell As String, ByVal OfferID As String, ByVal PL As Double, ByVal Commission As Double, ByVal AccountID As String)
    12. Delegate Sub DelegatefirstaddTrades(ByVal TradeID As String, ByVal OpenOrderID As String, ByVal UsedMargin As Double, ByVal OpenRate As Double, ByVal Amount As Integer, ByVal Limit As Double, ByVal Stoploss As Double, ByVal OpenTime As Date, ByVal GrossPL As Double, ByVal BuySell As String, ByVal offerID As String, ByVal PL As Double, ByVal Commission As Double)
    13. Delegate Sub DelegateLimitTrades(ByVal TradeID As String, ByVal OpenOrderID As String, ByVal UsedMargin As Double, ByVal OpenRate As Double, ByVal Amount As Integer, ByVal Limit As Double, ByVal Stoploss As Double, ByVal OpenTime As Date, ByVal GrossPL As Double, ByVal BuySell As String, ByVal OfferID As String, ByVal PL As Double, ByVal Commission As Double, ByVal AccountID As String)
    14. Private Sub Form5_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    15. Me.MdiParent = TZAutoTradingTool
    16. Me.Location = New Point(-2 + Form1.Size.Width, -1)
    17. End Sub
    18. Private Sub Form5_LocationChanged(sender As Object, e As EventArgs) Handles Me.LocationChanged
    19. Me.Location = New Point(-2 + Form1.Size.Width, -1)
    20. End Sub
    21. Public Sub UpdateTrades(ByVal TradeID As String, ByVal OpenOrderID As String, ByVal UsedMargin As Double, ByVal OpenRate As Double, ByVal Amount As Integer, _
    22. ByVal Limit As Double, ByVal Stoploss As Double, ByVal OpenTime As Date, ByVal GrossPL As Double, ByVal BuySell As String, _
    23. ByVal OfferID As String, ByVal PL As Double, ByVal Commission As Double)
    24. Me.BeginInvoke(New DelegatefirstaddTrades(AddressOf firstAddTrades2), New Object() {TradeID, OpenOrderID, UsedMargin, OpenRate, Amount, _
    25. Limit, Stoploss, OpenTime, GrossPL, BuySell, OfferID, PL, Commission})
    26. End Sub
    27. Public Sub firstAddTrades2(ByVal TradeID As String, ByVal OpenOrderID As String, ByVal UsedMargin As Double, ByVal OpenRate As Double, ByVal Amount As Integer, _
    28. ByVal Limit As Double, ByVal Stoploss As Double, ByVal OpenTime As Date, ByVal GrossPL As Double, ByVal BuySell As String, _
    29. ByVal OfferID As String, ByVal PL As Double, ByVal commission As Double)
    30. For i = 0 To Me.DataGridView4.Rows.Count - 1
    31. If OfferID = CStr(Me.DataGridView4.Rows(i).Cells(12).Value) Then
    32. Me.datagrid4(i, 9) = True
    33. End If
    34. Next
    35. End Sub
    36. Public Sub UpdatePriceInfo(ByVal Innstrument As String, ByVal bid As Double, ByVal ask As Double, ByVal offerID As String, ByVal pipcost As Double)
    37. Me.BeginInvoke(New DelegateUpdatePriceInfo(AddressOf UpdatePriceInfo2), New Object() {Innstrument, bid, ask, offerID, pipcost})
    38. End Sub
    39. Public Sub UpdatePriceInfo2(ByVal Instrument As String, ByVal bid As Double, ByVal ask As Double, ByVal offerID As String, ByVal pipcost As Double)
    40. Try
    41. Dim i, i2, amount, posm5, posm15, posm60 As Integer
    42. Dim stoploss, umrechnung As Double
    43. Dim tabellem5, tabellem15, tabellem60 As DataTable
    44. Dim LLS, SSL, makeorder As Boolean
    45. Dim buysell, buysell1, anzeige As String
    46. Dim create As New Create_Order(Form1)
    47. Dim Tag = System.DateTime.Now.DayOfWeek
    48. Dim stunde = System.DateTime.Now
    49. Dim zeitakt As Date
    50. Dim RSI As Object
    51. makeorder = False
    52. LLS = False
    53. SSL = False
    54. zeitakt = CDate(stunde.ToString("HH:mm"))
    55. If Tag = DayOfWeek.Saturday Then
    56. Exit Sub
    57. ElseIf Tag = DayOfWeek.Sunday And zeitakt < CDate("23:59") Then
    58. Exit Sub
    59. ElseIf HystoryForm.reloadema = True Or HystoryForm.update2 = True Or Form2.update3 = True Then
    60. Exit Sub
    61. End If
    62. For i = 0 To Me.DataGridView4.Rows.Count - 1
    63. arrayeintragen2(offerID)
    64. If CStr(Me.datagrid4(i, 0)) = Instrument Then
    65. umrechnung = einstellung.umrechnung(Instrument)
    66. SyncLock offerID
    67. Try
    68. tabellem5 = HystoryForm.Setm5.Tables(Instrument)
    69. tabellem15 = HystoryForm.Setm15.Tables(Instrument)
    70. tabellem60 = HystoryForm.Setm60.Tables(Instrument)
    71. posm5 = tabellem5.Rows.Count - 1
    72. posm15 = tabellem15.Rows.Count - 1
    73. posm60 = tabellem60.Rows.Count - 1
    74. Me.datagrid4(i, 1) = bid
    75. Me.datagrid4(i, 2) = ask
    76. Me.datagrid4(i, 3) = CDbl(tabellem5.Rows(posm5).Item(10))
    77. Me.datagrid4(i, 4) = CDbl(tabellem5.Rows(posm5).Item(11))
    78. Me.datagrid4(i, 6) = CStr(tabellem15.Rows(posm15).Item(5))
    79. Me.datagrid4(i, 7) = CStr(tabellem15.Rows(posm15 - 1).Item(5))
    80. Me.datagrid4(i, 8) = CStr(tabellem15.Rows(posm15).Item(5))
    81. Me.datagrid4(i, 12) = offerID
    82. Me.datagrid4(i, 20) = CDbl(tabellem15.Rows(posm15).Item(2))
    83. Me.datagrid4(i, 27) = CDbl(tabellem15.Rows(posm15).Item(12))
    84. Me.datagrid4(i, 28) = CDbl(tabellem15.Rows(posm15).Item(13))
    85. Me.datagrid4(i, 29) = CStr(tabellem15.Rows(posm15).Item(19))
    86. Catch ex As Exception
    87. MsgBox("Fehler:" & ex.StackTrace & "wo:" & ex.Message & "wert" & CStr(RSI))
    88. End Try
    89. If ClosingTrades.nextdel = True And Form3.DataGridView7.Rows.Count - 1 < 0 Then
    90. Form8.DataGridView10.Rows.Clear()
    91. ClosingTrades.pipos = False
    92. ClosingTrades.pipspos = 0
    93. ClosingTrades.pipspostime = 0
    94. ClosingTrades.anzahl = 0
    95. ClosingTrades.nextdel = False
    96. ClosingTrades.emadeep = False
    97. Form6.CheckBox1.Checked = True
    98. Form6.CheckBox2.Checked = True
    99. Form6.CheckBox3.Checked = True
    100. Form6.CheckBox4.Checked = True
    101. End If
    102. If CBool(Me.datagrid4(i, 9)) = False And Form6.CheckBox1.Checked = True Then
    103. If long1.longtrade1(tabellem15, tabellem60) = True Then
    104. LLS = True
    105. buysell = "B"
    106. anzeige = "Longtrade_M15_1"
    107. GoTo order
    108. End If
    109. If Short1.Shorttrade1(tabellem15, tabellem60) = True Then
    110. LLS = True
    111. buysell = "S"
    112. anzeige = "Shorttrade_M15_1"
    113. GoTo order
    114. End If
    115. End If
    116. Dim aktuellzeit As String
    117. aktuellzeit = Date.UtcNow.ToString("HH:mm")
    118. order:
    119. SyncLock offerID
    120. If CBool(Me.datagrid4(i, 9)) = False Then
    121. amount = amountberechnen(CStr(Me.datagrid4(i, 0)))
    122. 'If Tag = DayOfWeek.Friday And zeitakt >= CDate("18:00") Then
    123. ' Grideintragen(i, i2)
    124. ' Exit Sub
    125. 'End If
    126. 'Tradeabruch
    127. If Form3.DataGridView7.Rows.Count >= 8 Then
    128. Grideintragen(i, i2)
    129. Exit Sub
    130. End If
    131. If HystoryForm.reloadema = True Then
    132. Grideintragen(i, i2)
    133. Exit Sub
    134. End If
    135. If Form6.CheckBox1.Checked = False Then
    136. Grideintragen(i, i2)
    137. Exit Sub
    138. End If
    139. anzeige = anzeige
    140. If LLS = True Then
    141. stoploss = stoplossberechne(Instrument, bid, ask, buysell)
    142. Me.datagrid4(i, 9) = True
    143. Me.datagrid4(i, 5) = anzeige
    144. Me.datagrid4(i, 13) = 0
    145. Me.datagrid4(i, 14) = 0
    146. Me.datagrid4(i, 15) = 0
    147. Me.datagrid4(i, 16) = 0
    148. Me.datagrid4(i, 17) = 0
    149. Me.datagrid4(i, 18) = 0
    150. Me.datagrid4(i, 19) = 0
    151. Me.datagrid4(i, 31) = CDbl(tabellem15.Rows(tabellem15.Rows.Count - 1).Item(8))
    152. Me.datagrid4(i, 32) = CDbl(tabellem15.Rows(tabellem15.Rows.Count - 1).Item(9))
    153. Me.datagrid4(i, 33) = Me.datagrid4(i, 29)
    154. Me.datagrid4(i, 34) = 0
    155. Me.datagrid4(i, 35) = 0
    156. Me.datagrid4(i, 36) = "Open"
    157. Me.datagrid4(i, 37) = 0
    158. Me.datagrid4(i, 38) = 0
    159. Me.datagrid4(i, 39) = 0
    160. Me.datagrid4(i, 40) = 0
    161. create.Create_TrueMarketOrder(Form1.MySession, CStr(Form1.DataGridView1.Rows(0).Cells(1).Value), offerID, amount, buysell, stoploss)
    162. Exit For
    163. End If
    164. End If
    165. End SyncLock
    166. End SyncLock
    167. End If
    168. Grideintragen2(i)
    169. Next
    170. Catch ex As Exception
    171. MsgBox("Fehler:" & ex.StackTrace & "wo:" & ex.Message & "wert")
    172. End Try
    173. End Sub
    174. ' andere functionen, die aber bis dato sehr gut funktioniert haben.

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Rattenfänger“ ()

    was nein, ist ne Form? long1 ist ne Form? oder wird aus einer Form in eine Form gegrabscht?

    aber hat doch was mit Threading zu tun, odr?

    Nur finde ich in dem Vielen Code nicht mehr die Zeile, wo die Code-Ausführung auf einmal "verschwindet".

    Das Layout ist auch völlig zerschossen, ich erkenne gar keine Methoden und Zeugs.
    wie kann ich den code reinkopieren ohne diese vielen Leerzeilen?

    vlt. besser so.

    also longtrade ist die friendclass (kein modul) (das meinte ich mit nein). die form greift auf die klasse zu.
    mit dem threading hat es evtl nicht viel zu tun der der code lief ja.

    VB.NET-Quellcode

    1. If CBool(Me.datagrid4(i, 9)) = False And Form6.CheckBox1.Checked = True Then
    2. If CStr(tabellem60.Rows(posm60).Item(19)) = "Long" And CStr(tabellem60.Rows(posm60 - 20).Item(19)) = "Short" _
    3. andd CDbl(tabellem60.Rows(posm60).Item(20)) >= 0.1 And CDbl(tabellem60.Rows(posm60).Item(20)) <= 1.0 _
    4. And CStr(tabellem15.Rows(posm15).Item(19)) = "Long" _
    5. And CDbl(tabellem15.Rows(posm15).Item(20)) >= 0.5 And CDbl(tabellem15.Rows(posm15).Item(20)) <= 3.0 Then
    6. LLS = True
    7. buysell = "B"
    8. anzeige = "Longtrade_M15"
    9. GoTo order
    10. End If
    11.  
    12. If CStr(tabellem60.Rows(posm60).Item(19)) = "Short" And CStr(tabellem60.Rows(posm60 - 20).Item(19)) = "Long" _
    13. And CDbl(tabellem60.Rows(posm60).Item(20)) >= 0.1 And CDbl(tabellem60.Rows(posm60).Item(20)) <= 1.0 _
    14. And CStr(tabellem15.Rows(posm15).Item(19)) = "Short" _
    15. And CDbl(tabellem15.Rows(posm15).Item(20)) >= 0.5 And CDbl(tabellem15.Rows(posm15).Item(20)) <= 3.0 Then
    16. LLS = True
    17. buysell = "S"
    18. anzeige = "Shorttrade_M15"
    19. GoTo order
    20. End If
    21. End If


    Das war der code vorher, mit dem hats funktioniert, da ich aber sauviele Funktionen, mit verschiedenen abfrage Funktionen programmieren möchte,
    ist das blöd alles in eine klasse oder Sub zu packen.

    deshalb habe ich es hiermit ersetzt:

    VB.NET-Quellcode

    1. If CBool(Me.datagrid4(i, 9)) = False And Form6.CheckBox1.Checked = True Then
    2. If long1.longtrade1(tabellem15, tabellem60) = True Then 'das hier ruft er nichtmal auf!!! und steigt schon im MDI parent in Wartefunktion!
    3. LLS = True
    4. buysell = "B"
    5. anzeige = "Longtrade_M15_1"
    6. GoTo order
    7. End If
    8. If Short1.Shorttrade1(tabellem15, tabellem60) = True Then
    9. LLS = True
    10. buysell = "S"
    11. anzeige = "Shorttrade_M15_1"
    12. GoTo order
    13. End If
    14. End If


    und es ist kein weitere thread, hinzugekommen.

    Dim long1 As New Longtrade
    Dim Short1 As New Shorttrade

    so habe ich auf die beiden neuen Klassen verwiesen.
    Nein soll eine nur eine Klasse sein, hatte es testweise in eine Friend class umgewandelt, sowie die inherits hinzugefügt.
    Wurde wieder Rückgängig gemacht.

    Habe jetzt eine Fehlermeldung bekommen.

    Genau an der fehlerhaften stelle. Ihm fehlt ein Objektverweis!?
    keine Ahnung, ich kann dir nicht folgen, ich weiß nicht die fehlerhafte stelle, und bei den 300 total unübersichtlichen Zeilen wird mir das vmtl. auch nix nützen, die fehlerhafte stelle näher kennenzulernen.

    Nur einzelne Zeilen stechen für mich da hervor, die auf eine falsche Architektur hindeuten, etwa sowas:

    Rattenfänger schrieb:

    VB.NET-Quellcode

    1. tabellem15 = HystoryForm.Setm15.Tables(Instrument)
    oder sowas:

    Rattenfänger schrieb:

    VB.NET-Quellcode

    1. Form6.CheckBox1.Checked = True

    Das sieht für mich aus, als ob da in andere Forms gegrabscht wird, aber du sagst ja, sowas würdest du nicht tun - naja, musst du wissen.
    Wenn es bei dir ein Form6 gibt, und ein HystoryForm, und das sind Forms - wie gesagt ...

    Und die ganzen Delegaten-Deklarationen deuten stark auf Threading hin, aber auch dieser Vermutung widersprichst du.

    Rattenfänger schrieb:

    VB.NET-Quellcode

    1. Delegate Sub DelegateUpdatePriceInfo(ByVal Innstrument As String, ByVal bid As Double, ByVal ask As Double, ByVal offerID As String, ByVal pipcost As Double)
    2. Delegate Sub DelegateUpdateTrades2(ByVal TradeID As String, ByVal OpenOrderID As String, ByVal UsedMargin As Double, ByVal OpenRate As Double, ByVal Amount As Integer, ByVal Limit As Double, ByVal Stoploss As Double, ByVal OpenTime As Date, ByVal GrossPL As Double, ByVal BuySell As String, ByVal OfferID As String, ByVal PL As Double, ByVal Commission As Double, ByVal AccountID As String)
    3. Delegate Sub DelegatefirstaddTrades(ByVal TradeID As String, ByVal OpenOrderID As String, ByVal UsedMargin As Double, ByVal OpenRate As Double, ByVal Amount As Integer, ByVal Limit As Double, ByVal Stoploss As Double, ByVal OpenTime As Date, ByVal GrossPL As Double, ByVal BuySell As String, ByVal offerID As String, ByVal PL As Double, ByVal Commission As Double)
    4. Delegate Sub DelegateLimitTrades(ByVal TradeID As String, ByVal OpenOrderID As String, ByVal UsedMargin As Double, ByVal OpenRate As Double, ByVal Amount As Integer, ByVal Limit As Double, ByVal Stoploss As Double, ByVal OpenTime As Date, ByVal GrossPL As Double, ByVal BuySell As String, ByVal OfferID As String, ByVal PL As Double, ByVal Commission As Double, ByVal AccountID As String)




    Also ich keine Ahnung ?(
    ok, anscheinend haben wir ein kleines Verständigungsproblem. Ja das kpl. Programm ist Multithreading!

    jedoch wird kein weiter Thread aus der Sub neu erstellt. Die Funktion Longtrade greift nicht auf eine andere Form zu.
    Das du jetzt soweit ins Detail gehst(vom deinem geistigen denken) wusste ich nicht. :-)! Mann merkt das du das schon länger machst ;-)!

    Problem habe ich jetzt gelöst!!! in dem ich jede function die tabels zugewiesen habe.

    VB.NET-Quellcode

    1. If CBool(Me.datagrid4(i, 9)) = False And Form6.CheckBox1.Checked = True Then
    2. If long1.longtrade1(Instrument) = True Then
    3. LLS = True
    4. buysell = "B"
    5. anzeige = "Longtrade_M15_1"
    6. GoTo order
    7. End If
    8. If Short1.Shorttrade1(Instrument) = True Then
    9. LLS = True
    10. buysell = "S"
    11. anzeige = "Shorttrade_M15_1"
    12. GoTo order
    13. End If
    14. End If
    15. [vbnet]

    Dim ergebniss As Boolean = False
    Dim tabellem5, tabellem15, tabellem30, tabellem60 As DataTable
    Dim posm30, posm5, posm15, posm60 As Integer

    tabellem5 = HystoryForm.Setm5.Tables(Instrument)
    tabellem15 = HystoryForm.Setm15.Tables(Instrument)
    tabellem30 = HystoryForm.Setm30.Tables(Instrument)
    tabellem60 = HystoryForm.Setm60.Tables(Instrument)

    posm5 = tabellem5.Rows.Count - 1
    posm15 = tabellem15.Rows.Count - 1
    posm30 = tabellem30.Rows.Count - 1
    posm60 = tabellem60.Rows.Count - 1

    If EMA.EMAzwischen(Instrument, "m15", 2.5, 10, 5, "Short") = True And EMA.EMAsinkt(Instrument, "m15", posm15, 5, "Short", 1.0, 0.2) = True _
    and EMA.EMAsinkt(Instrument, "m60", posm60, 10, "Short", 1.0, 0.2) = True Then
    if DMI.DMIgrößer(Instrument, "m15", "DMIM", 25.0, 10) = True And DMI.DMIkleiner(Instrument, "m15", "DMIP", 15, 10) = True _
    And DMI.DMIMsinkt(Instrument, "m15", posm15, 5, 5, 0.2) = True Then
    ergebniss = True
    end If

    End If
    Return ergebniss
    end Function

    [/vbnet]

    was währe den besser?

    soll ich ich direkt auf die die datasets zugreifen, also den ganzen müll den ich in die hystoryform habe in die einzelnen datasets einbauen und geht das überhaupt?


    So EDR, du bist ein Genie(du hattest mir die frage gestellt ob es module sind,deshalb?). Habe jetzt die Klassen in Module umgewandelt. Und es funktioniert perfekt.

    Aber warum und kann ich jetzt die datatables direkt an die einzelnen Funktion in den Modulen übergeben?
    die ruft die Funktion auf

    VB.NET-Quellcode

    1. Public class form1
    2. private Sub test1
    3. tabellem15 = HystoryForm.Setm15.Tables(Instrument)
    4. tabellem60 = HystoryForm.Setm60.Tables(Instrument)
    5. If longtrade1(tablem15,tabelm60) = True Then
    6. end if
    7. end Sub
    8. end class





    VB.NET-Quellcode

    1. Module test
    2. Public Function longtrade1(byval tabm1 as datatable, byval tab2 as datatable) as boolean
    3. 'auszuführender code
    4. end function
    5. end module



    Und ja du hast recht die Architektur ist nicht durchdacht bei meinem Projekt. Bin halt kein Profi und ich lerne jeden tag dazu :-)! Mache Hauptberuflich ja was anderes.
    Ähm, deine Frage lautete:

    Rattenfänger schrieb:

    Aber warum und kann ich jetzt die datatables direkt an die einzelnen Funktion in den Modulen übergeben?
    Bist du noch daran interessiert, oder hat sich das geklärt, oder ist dein Interesse daran verschwunden?


    Weil die Frage, ob das "geht", ist ja eine andere.


    Also falls du noch interesse hast, bitte beantworte meine Gegenfrage vollständig. Solange die Begriffe nicht klar sind, kann ich nur rumschwafeln.

    Also in post#16 sehe ich, was für dich "datatables direkt an die einzelnen Funktion in den Modulen übergeben" bedeutet. Das ist ja immerhin schonmal die hälfte der Antwort meiner Frage aus post#15.

    Beantwortest du noch den Rest, also was wäre ein Codebeispiel für "indirekt"?
    Also direkt funktioniert(habe es grad getestet, deshalb bin ich nicht anwesend gewesen)!Und natürlich bin ich noch interessiert!!!

    VB.NET-Quellcode

    1. Public Class Form1
    2. Public Sub test
    3. tabellem15 = HystoryForm.Setm15.Tables(Instrument)
    4. tabellem60 = HystoryForm.Setm60.Tables(Instrument)
    5. If longtrade1(instrument) = True Then
    6. end if
    7. end sub
    8. End class
    9. Module longtrade
    10. public function Longtrade1(byval Instrument as string) as booelean
    11. dim tabelm15,tabelm60 as datatable
    12. tabelm15 = hystoryform.setm15.tabel(Instrument)
    13. tabelm60 = hystoryform.setm60.tabel(Instrument)
    14. end Function
    15. end module


    das ist indirect, da ich erst in der ausführenden function auf die tabels verweise.

    Aber warum funktioniert das direkte verweisen auf Module und nicht in Klassen? Ich formuliere die frage mal um, warum kann ich an eine function die in einem Module ist, eine Table übergeben und wenn die function in einer Klasse ist, muss ich den verweis in der klasse erstellen?