You are on page 1of 5

Attribute VB_Name = "Module1"

Public Declare Function GetLocaleInfo Lib "kernel32" Alias


"GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal
lpLCData As String, ByVal cchData As Long) As Long
Public Declare Function SetLocaleInfo Lib "kernel32" Alias
"SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal
lpLCData As String) As Long
Public Const LOCALE_SLONGDATE As Long = &H20
Public Const LOCALE_SSHORTDATE As Long = &H1F
Public Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long

'****************************************************************
' Name: Bin
' ' Description:Converts BIN ---> DEC.
'****************************************************************
Function Bin%(b$)
bTemp% = 0
t$ = Right$(String$(16, "0") + b$, 16)

If Left$(t$, 1) = "1" Then


bTemp% = &H8000
End If

mask% = &H4000

For i% = 2 To 16

If Mid$(t$, i%, 1) = "1" Then


bTemp% = bTemp% Or mask%
End If

mask% = mask% \ 2
Next i%

Bin% = bTemp%
End Function

'****************************************************************
' Name: Bin2Long
' Description:converting from a string of binary bits to int
' eger is a snap! voltzNOSPAM@ovnet.com
' By: Newsgroup Posting
'
' Inputs:None
' Returns:None
' Assumes:None
' Side Effects:None
'
'Code provided by Planet Source Code(tm) 'as is', without
' warranties as to performance, fitness, merchantability,
' and any other warranty (whether expressed or implied).
'****************************************************************

Function Bin2Long(ByVal b As String) As Long

Dim o As Long, i As Integer


o = 0
For i = Len(b) To 1 Step -1
If Mid(b, i, 1) = "1" Then
o = o + 2 ^ (Len(b) - i)
End If
Next i
Bin2Long = o
End Function

'****************************************************************
' Name: Converting Decimal numbers to Binary
' Description:A function for converting decimal numbers to b
' inary. Very fast.
' By: K. Mehdi
'
' Inputs:Decimal number (Long)
' Returns:Binary number (string)
' Assumes:None
' Side Effects:None
'
'Code provided by Planet Source Code(tm) 'as is', without
' warranties as to performance, fitness, merchantability,
' and any other warranty (whether expressed or implied).
'****************************************************************

Function dec2bin(ByVal decvalue As Long)


'decvalue = Val(Text1.Text)
binvalue = ""

Do
TempValue = decvalue Mod 2
binvalue = CStr(TempValue) + binvalue
decvalue = decvalue \ 2
Loop Until decvalue = 0
dec2bin = binvalue
End Function

'****************************************************************
' Name: Convert hex to integer
' ' Description:Convert hex to integer.
' "Shawn Lee" <shawnlee@cris.com>
' By: Newsgroup Posting
'
' Inputs:None
' Returns:None
' Assumes:None
' Side Effects:None
'
'Code provided by Planet Source Code(tm) 'as is', without
' warranties as to performance, fitness, merchantability,
' and any other warranty (whether expressed or implied).
'****************************************************************

'lngColor = CLng("&H" & strHex)


Public Function hex2dec3(ByVal hexa$) As Integer
' preparada para recibir solo dos caracteres y devolver el entero
Dim hexa1, hexa2, hexa3
If Len(hexa$) < 3 Then
hexa$ = Right$(String$(3, "0") + hexa$, 3)

End If
Select Case Mid(hexa$, 1, 1)
Case "A"
hexa1 = 10
Case "B"
hexa1 = 11
Case "C"
hexa1 = 12
Case "D"
hexa1 = 13
Case "E"
hexa1 = 14
Case "F"
hexa1 = 15
Case Else: hexa1 = Mid(hexa$, 1, 1)
End Select
Select Case Mid(hexa$, 2, 1)
Case "A"
hexa2 = 10
Case "B"
hexa2 = 11
Case "C"
hexa2 = 12
Case "D"
hexa2 = 13
Case "E"
hexa2 = 14
Case "F"
hexa2 = 15
Case Else: hexa2 = Mid(hexa$, 2, 1)
End Select
Select Case Mid(hexa$, 3, 1)
Case "A"
hexa3 = 10
Case "B"
hexa3 = 11
Case "C"
hexa3 = 12
Case "D"
hexa3 = 13
Case "E"
hexa3 = 14
Case "F"
hexa3 = 15
Case Else: hexa3 = Mid(hexa$, 3, 1)
End Select

hex2dec3 = Val(hexa1) * 32 + Val(hexa2) * 16 + Val(hexa3)

End Function
Public Function hex2dec(ByVal hexa$) As Integer
' preparada para recibir solo dos caracteres y devolver el entero
Dim hexa1, hexa2
If Len(hexa$) < 2 Then
hexa$ = Right$(String$(2, "0") + hexa$, 2)

End If
Select Case Mid(hexa$, 1, 1)
Case "A"
hexa1 = 10
Case "B"
hexa1 = 11
Case "C"
hexa1 = 12
Case "D"
hexa1 = 13
Case "E"
hexa1 = 14
Case "F"
hexa1 = 15
Case Else: hexa1 = Mid(hexa$, 1, 1)
End Select
Select Case Mid(hexa$, 2, 1)
Case "A"
hexa2 = 10
Case "B"
hexa2 = 11
Case "C"
hexa2 = 12
Case "D"
hexa2 = 13
Case "E"
hexa2 = 14
Case "F"
hexa2 = 15
Case Else: hexa2 = Mid(hexa$, 2, 1)
End Select
hex2dec = Val(hexa1) * 16 + Val(hexa2)

End Function
Public Function xor_propio(b1$, b2$) As String
Dim i As Integer
Dim s1, s2, s3
s3 = ""
b1$ = Right$(String$(8, "0") + b1$, 8)
b2$ = Right$(String$(8, "0") + b2$, 8)
For i = 1 To 8
s1 = Mid(b1$, i, 1)
s2 = Mid(b2$, i, 1)
s3 = s3 & (s1 Xor s2)

Next i
xor_propio = s3
End Function

Public Sub delay(pausa As Integer)


Dim inicio As Single
inicio = Timer
Do While Timer < inicio + pausa
DoEvents
If Timer < inicio Then
Exit Do
End If
Loop
inicio = 0
End Sub

You might also like