Argument nicht optional
Verfasst: Mo, 19.09.2005 10:55
Kann mir einer bitte erklären wo mein Fehler liegt?
Ich bekomme immer die fehlermeldung: Argument nicht optional für die Zeile: IsBitSet = GetBitNum( nBits, nBitNum ) > 0
Hier der Code! Die BitManipultaionFunctions sind aus dem Englischem OOo Forum und sollten eigentlich problemlos laufen. Von mir, zum Testen der Funktionen stammt nur testBitFunction
Ich bekomme immer die fehlermeldung: Argument nicht optional für die Zeile: IsBitSet = GetBitNum( nBits, nBitNum ) > 0
Hier der Code! Die BitManipultaionFunctions sind aus dem Englischem OOo Forum und sollten eigentlich problemlos laufen. Von mir, zum Testen der Funktionen stammt nur testBitFunction
Code: Alles auswählen
'############################################################
' Bit manipulation functions.
'############################################################
' Return True if a particular bit in nBits is set.
' Bit 0 is the least significant bit.
'Function IsBitSet(nBits As Long, nBitNum As Integer ) As Boolean
' IsBitSet = GetBitNum( nBits, nBitNum ) > 0
'End Function
' Return a particular bit from nBits.
' Bit 0 is the least significant bit.
Function GetBitNum(ByVal nBits As Long, ByVal nBitNum As Integer ) As Long
Do While nBitNum > 0
nBitNum = nBitNum - 1
nBits = Int( nBits / 2 ) ' shift right
Loop
GetBitNum = nBits Mod 2
End Function
' Set a particular bit in nBits.
' It does not matter what the previous status of the bit was,
' end ends up as a 1 bit.
' Bit 0 is the least significant bit.
Function SetBit( ByVal nBits As Long, ByVal nBitNum As Integer ) As Long
nBit = 1
Do While nBitNum > 0
nBitNum = nBitNum - 1
nBit = nBit * 2 ' shift left
Loop
SetBit = nBits Or nBit
End Function
' Clear a particular bit in nBits.
' It does not matter what the previous status of the bit was,
' end ends up as a 0 bit.
' Bit 0 is the least significant bit.
Function ClearBit( ByVal nBits As Long, ByVal nBitNum As Integer ) As Long
Dim nBit As Long
nBit = 1
Do While nBitNum > 0
nBitNum = nBitNum - 1
nBit = nBit * 2 ' shift left
Loop
ClearBit = nBits And (Not nBit)
End Function
Sub testBitFunction
Dim nBit as Long
nBit = "1001001011011"
msgbox GetBitNum(nBit, 2)
End Sub