Topaz Filer: if you use e-mail for business, we can save you money and decrease your risk.
LSET Upgrade
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.vb.upgrade.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Tracy Walton
Has anyone successfully been able to replicate the LSET
statement from VB into the .NET environment? I am trying
to modify some legacy code that uses the statement but am
having difficulty coming up with a workable replacement...
Thanks

Reply to this message...
Vote that this is a GOOD answer...
 
Auto-following on Twitter
Ubuntu and XP on one “desktop”
 
    
Herfried K. Wagner [MVP] (VIP)
* "Tracy Walton" <Click here to reveal e-mail address> scripsit:
[Original message clipped]

"Post code."

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Tracy Walton
'Some private types used to do bit hammering in a language
'that doesn't support bit hammering.
Public Type DoubleInteger
LowInt As Integer
HiInt As Integer
End Type

Public Type SingleLong
FullLong As Long
End Type

'Constant to fish out various bits.
Public Const WarningMask As Integer = &H800
Public Const FacilityMask As Integer = &H7FF

Public Function IsWin32Code(ByVal ErrorNumber As Long) As Boolean

'This function tests if the error returned came originally from
Win32. It returns True
'if the origin of the error was a Win32 function call.

Dim DI As DoubleInteger
Dim SL As SingleLong
SL.FullLong = ErrorNumber
LSet DI = SL

If (DI.HiInt And FacilityMask) = FC_Win32Error Then
IsWin32Code = True
Else
IsWin32Code = False
End If

End Function

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Tracy Walton
'Some private types used to do bit hammering in a language
'that doesn't support bit hammering.
Public Type DoubleInteger
LowInt As Integer
HiInt As Integer
End Type

Public Type SingleLong
FullLong As Long
End Type

'Constant to fish out various bits.
Public Const WarningMask As Integer = &H800
Public Const FacilityMask As Integer = &H7FF

Public Function IsWin32Code(ByVal ErrorNumber As Long) As Boolean

'This function tests if the error returned came originally from
Win32. It returns True
'if the origin of the error was a Win32 function call.

Dim DI As DoubleInteger
Dim SL As SingleLong
SL.FullLong = ErrorNumber
LSet DI = SL

If (DI.HiInt And FacilityMask) = FC_Win32Error Then
IsWin32Code = True
Else
IsWin32Code = False
End If

End Function

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Reply to this message...
Vote that this is a GOOD answer...
 
Outlook interop - stopping user properties appearing on Outlook message print
Seriously, why is “cut and paste” majorly newsworthy???
 
    
Paul Clement
On Tue, 13 Jan 2004 04:36:58 -0800, Tracy Walton <Click here to reveal e-mail address> wrote:

¤
¤ 'Some private types used to do bit hammering in a language
¤ 'that doesn't support bit hammering.
¤ Public Type DoubleInteger
¤ LowInt As Integer
¤ HiInt As Integer
¤ End Type
¤
¤ Public Type SingleLong
¤ FullLong As Long
¤ End Type
¤
¤ 'Constant to fish out various bits.
¤ Public Const WarningMask As Integer = &H800
¤ Public Const FacilityMask As Integer = &H7FF
¤
¤ Public Function IsWin32Code(ByVal ErrorNumber As Long) As Boolean
¤
¤ 'This function tests if the error returned came originally from
¤ Win32. It returns True
¤ 'if the origin of the error was a Win32 function call.
¤
¤
¤ Dim DI As DoubleInteger
¤ Dim SL As SingleLong
¤ SL.FullLong = ErrorNumber
¤ LSet DI = SL
¤
¤ If (DI.HiInt And FacilityMask) = FC_Win32Error Then
¤ IsWin32Code = True
¤ Else
¤ IsWin32Code = False
¤ End If
¤
¤ End Function

Here's a function that can split the high and low values of a 32-bit integer:

Public Sub SplitInt(ByVal Int32Val As Int32)

Dim ByteBuffer(3) As Byte
Dim LoWord As Int16
Dim HiWord As Int16

ByteBuffer = System.BitConverter.GetBytes(Int32Val)
LoWord = System.BitConverter.ToInt16(ByteBuffer, 0)
HiWord = System.BitConverter.ToInt16(ByteBuffer, 2)

End Sub

Paul ~~~ Click here to reveal e-mail address
Microsoft MVP (Visual Basic)
Reply to this message...
Vote that this is a GOOD answer...
 
Email Archiving and Email Filing - what’s the difference?
Web-based task/todo list management
 
    
Paul Clement
On Mon, 12 Jan 2004 05:29:21 -0800, "Tracy Walton" <Click here to reveal e-mail address> wrote:

¤ Has anyone successfully been able to replicate the LSET
¤ statement from VB into the .NET environment? I am trying
¤ to modify some legacy code that uses the statement but am
¤ having difficulty coming up with a workable replacement...

Could you provide an example of your LSET code?

Paul ~~~ Click here to reveal e-mail address
Microsoft MVP (Visual Basic)
Reply to this message...
Vote that this is a GOOD answer...
 
 
 
System.BitConverter




Ad
BootFX
Reliable and powerful .NET application framework.
Recession Busting Bespoke Software
Get through the recession by investing in bespoke software to decrease costs and create commercial opportunities.
Other DN247 Network Sites
.NET 247
SQL Server Wins
Old Skool Developer
 
Copyright © AMX Software Ltd 2008-2009. Portions copyright © Matthew Baxter-Reynolds 2001-2009. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - .NET 247 is a member of the DN247 Network - 4.0.30129.1734