Autor Beitrag
Delphi-Laie
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1600
Erhaltene Danke: 232


Delphi 2 - RAD-Studio 10.1 Berlin
BeitragVerfasst: Do 20.04.17 18:35 
Hallo Programmierfreunde!

Wer kennt sich mit Visual Basic näher aus?

Die Übergabeparameter bei Unterprogrammen (Funktionen) können ByVal und ByRef deklariert werden. Entspricht dem fehlenden (Werte-) bzw. var- bzw. Variablen-Parameter in Pascal / Delphi (Delphi kennt zudem auch noch den Ausgabe-/Variablenparameter "out" sowie "const"). Soweit so gut.

Nun stoße ich aber in Visual Basic erstmalig auf Variablenübergabe ohne einen Parameter, also weder ByVal noch ByRef.

Das zu "googeln" ist schwierig, denn wie soll man ein fehlendes, nichtexistentes Wort suchen?

Mein Experiment ergab, daß es wohl am ehesten mit "ByRef" (bzw. "var" in Pacal / Delphi) korrespondiert. Ist das korrekt, oder gibt es da noch irgendwelche Tücken, Fallstricke?

Danke und Gruß

Delphi-Laie

Ergänzung: Es geht um ein Modul, in dem fünf Funktionen enthalten sind. In allen Funktionsköpfen sind bei manchen Übergabeparametern/Variablen weder "ByRef" noch "ByVal" vorhanden:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
Function BuildSubHeap(theData() As DataElement, lngNoElements As Long, lngHeapTop As Long, lngLeftSize As Long, lngLeftRightBits As Long, lngHeapNo As Long, heapHeadsIndexes() As Long, heapHeadsLeftSizes() As Long, heapHeadsLeftRightBits() As Long)

Function PushDownLeftFirst(theData() As DataElement, lngNoElements As Long, lngHeapTop As Long, lngLeftSize As Long, lngLeftRightBits As Long, lngHeapNo As Long, heapHeadsIndexes() As Long, heapHeadsLeftSizes() As Long, heapHeadsLeftRightBits() As Long)

Function RotateEqualValues(ByRef theData() As DataElement, ByVal lngNoElements As Long, ByVal lngHeapTop As Long, ByVal lngLeftSize As Long, lngLeftRightBits As Long, lngHeapNo As Long, heapHeadsIndexes() As Long, heapHeadsLeftSizes() As Long, heapHeadsLeftRightBits() As Long)

Function FindLastEqualValue(ByRef theData() As DataElement, ByVal lngNoElements As Long, ByVal lngHeapTop As Long, ByVal lngLeftSize As Long, ByVal lngLeftRightBits As Long, ByVal lngHeapNo As Long, heapHeadsIndexes() As Long, heapHeadsLeftSizes() As Long, heapHeadsLeftRightBits() As Long, ByRef lngLastLeftSize As Long, ByRef lngLastLeftRightBits As Long, ByRef lngLastHeapNo As Long) As Long

Function FindNextEqualValue(ByRef theData() As DataElement, ByVal lngNoElements As Long, ByVal lngHeapTop As Long, ByVal lngLeftSize As Long, lngLeftRightBits As Long, lngHeapNo As Long, heapHeadsIndexes() As Long, heapHeadsLeftSizes() As Long, heapHeadsLeftRightBits() As Long, ByRef lngNextLeftSize As Long, ByRef lngNextLeftRightBits As Long, ByRef lngNextHeapNo As Long) As Long


Was ist davon zu halten?


Zuletzt bearbeitet von Delphi-Laie am Fr 21.04.17 22:54, insgesamt 1-mal bearbeitet
Frühlingsrolle
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 21.04.17 05:01 
- Nachträglich durch die Entwickler-Ecke gelöscht -

Für diesen Beitrag haben gedankt: Delphi-Laie
Delphi-Laie Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1600
Erhaltene Danke: 232


Delphi 2 - RAD-Studio 10.1 Berlin
BeitragVerfasst: Fr 21.04.17 11:42 
Um ehrlich zu sein, daß gerade Du, Frühlingsrolle, mir antwortest, hatte ich fast vermutet, ja geahnt. Dankeschön!

Muß ich mir noch mal ansehen, ob es nicht doch eher ein Werte- denn ein Variablenparameter ist. Könnte ich fast wetten, daß es ohne dem "var"-Verhalten des Delphis entsprach.

Daß es ohne dem const (oder auch out) entspricht, hatte ich auch schon vermutet - jedoch erstmal nicht geprüft - scheint aber, wie ich eben ausprobierte, doch nicht so zu sein.
Frühlingsrolle
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 21.04.17 12:04 
- Nachträglich durch die Entwickler-Ecke gelöscht -

Für diesen Beitrag haben gedankt: Delphi-Laie
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 21.04.17 12:08 
blogs.msmvps.com/car...e-editor-experience/ hat folgendes geschrieben:

While in “classic” VB6 “ByRef” was the default and “ByVal” was required to pass parameters by value, in VB.NET it’s the opposite: “ByVal” is the default and “ByRef” is required to pass parameters by reference. However, until VS 2010 SP1, the VB.NET code editor always added “ByVal” when typing or when generating code (like in the parameters of event handlers).

Für diesen Beitrag haben gedankt: Delphi-Laie
Frühlingsrolle
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 21.04.17 12:16 
- Nachträglich durch die Entwickler-Ecke gelöscht -

Für diesen Beitrag haben gedankt: Delphi-Laie
Delphi-Laie Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1600
Erhaltene Danke: 232


Delphi 2 - RAD-Studio 10.1 Berlin
BeitragVerfasst: Fr 21.04.17 13:35 
Das ist genau das, was ich (vergeblich) suchte, Sebastian!
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 21.04.17 15:24 
Vielleicht hilft es dir ja, wenn ich mal poste wonach ich gesucht habe (direkt im ersten Versuch):
Suche bei Google VISUAL BASIC PARAMETER WITHOUT BYVAL/BYREF
Denn oft fehlt da ja wirklich die Inspiration wie man eingibt was man sucht. ;-)

In dem StackOverflow Ergebnis, bei mir an Position 2, habe ich dann den Link gefunden.

Für diesen Beitrag haben gedankt: Delphi-Laie
Delphi-Laie Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1600
Erhaltene Danke: 232


Delphi 2 - RAD-Studio 10.1 Berlin
BeitragVerfasst: Fr 21.04.17 16:12 
Nunja, ich suchte nach "ohne" bzw. "ohne Parameter", auch mit "ByVal" und "ByRef", uns sogar explizit in deutschsprachigen VB-Foren...

Edit: Der Algorithmus läuft jetzt auch als Delphi-Quelltext....danke nochmal Euch beiden!