VB里另一种更高效的Base64编码与解码算法
Option Explicit
'名称: Base64编码/解码模块
'Name: Base64 Encode & Decode Module
'作者: KiteGirl [中国]
'programmer: KiteGirl [China]
Private priBitMoveTable() As Byte '移位缓冲表
Private priBitMoveTable_CellReady() As Boolean '移位缓冲表标志表
Private priBitMoveTable_Create As Boolean '移位缓冲表创建标志
Private priEncodeTable() As Byte '编码表(素码转Base64)
Private priEncodeTable_Create As Boolean
Private priDecodeTable() As Byte '解码表(Base64转素码)
Private priDecodeTable_Create As Boolean
Private Declare Sub Base64_CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef pDestination As Any, ByRef pSource As Any, ByVal pLength As Long)
Private Const conBase64_CodeTableStrng As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
Private Const conBase64_PatchCode As Byte = 61
Private Type tpBase64_Dollop2438 '24Bit(8Bit*3Byte)数据块
btBytes(0 To 2) As Byte
End Type
Private Type tpBase64_Dollop2446 '24Bit(6Bit*4Byte)数据块
btBytes(0 To 3) As Byte
End Type
'解码
Public Sub Base64_Decode(ByRef tOutBytes() As Byte, ByRef pBytes() As Byte, Optional ByVal pPatchCode As Byte = conBase64_PatchCode)
'Base64Decode函数
'语法:[tOutBytes()] = Base64Decode(pBytes(), [pPatchCode])
'功能:将Byte数组表示的Base64编码Ascii字节数组解码为Byte字节数组,并返回。
'参数:byte pBytes() '必要参数。Byte数组表示的Base64编码数据。
' byte pPatchCode '可选参数。冗余字节追加码。默认为61("="的Ascii码)
'返回:byte tOutBytes() 'Byte数组。
'示例:
' Dim tSurString As String
' Dim tSurBytes() As Byte
' tSurString = "S2l0ZUdpcmzKx7j2usO6otfT"
' tSurBytes() = StrConv(tSurString, vbfromUnicode)
' Dim tDesString As String
' Dim tDesBytes() As Byte
' tDesBytes() = Base64Decode(tSurBy
相关文档:
通过调用CreateDataSetfromXml取得XML数据
Imports System.Xml
Public Const FILE_CONFIG = "MZZ.xml"
Public Const PATH_CONFIG = "\XML\"
Dim dstXML As DataSet
Dim tblXML_DB As DataTable
Dim dtCod As New DataTable
Dim strSQL As String = ""
clsPublic ......
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Const EWX_LOGOFF = 0
Private Const EWX_SHUTDOWN = 1
Private Const EWX_REBOOT = 2
Private Const EWX_FORCE = 4
Private closeTime As String
Sub AdjustTokenPrivilegesForNT()
......
主窗体代码:
'打开网页
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
'复制文件
Private Declare Fu ......
在开发中保持良好的编码规范是十分重要的。我所采用的新的VB.net/ASP.NET编码规范,是一种被证明能明显改善代码可读性,并有助于代码管理、分类的编码规范。采用这种编码规范,能避免如匈牙利命名法带来的繁长前缀,便于记忆变量的用途。下面的介绍这种编码规范。
一、类型级单位的命名
1、类
□以Class声明的类,都必须 ......