⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modextrafunctions.vb.svn-base

📁 MirUnleashed vb.net Module modMainServer Public WithEvents Socket As New WinsockServer Pub
💻 SVN-BASE
字号:
Imports System.Text.Encoding

Module modExtraFunctions

#Region "AddLog Code"

    Public Sub AddLog(ByVal Title As String, ByVal Message As String)
        FrmMain.lstLog.Items.Add("[" & Title & "] " & Message)
        FrmMain.lstLog.SetSelected(FrmMain.lstLog.Items.Count - 1, True)
    End Sub

#End Region
#Region "GetTok Code"

    Public Function GetTok(ByVal Data As String, ByVal I As Integer, ByVal Delim As String) As String
        Dim DataArray() As String = Split(Data, Delim)
        If I < DataArray.Length Then
            Return DataArray(I)
        End If
        Return "failure"
    End Function

#End Region
#Region "IsValidString Code"

    Private ASCIIString As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"

    Public Function IsValidString(ByVal str As String) As Boolean
        Dim i As Integer
        For i = 0 To str.Length - 1
            If ASCIIString.IndexOf(str.Substring(i, 1)) < 0 Then
                Return True
            End If
        Next
        Return False
    End Function

#End Region
#Region "GetBetween"

    Public Function GetBetween(ByVal Str As String, ByVal sStart As String, ByVal sEnd As String) As String
        Str = GetTok(Str, 1, sStart)
        Str = GetTok(Str, 0, sEnd)
        Return Str
    End Function

#End Region
#Region "ToByte"

    Public Function ToByte(ByVal Value As Boolean) As Byte
        Select Case Value
            Case True
                Return 1
            Case False
                Return 0
        End Select
    End Function

#End Region
#Region "Rand Code"

    Dim RandomGen As New System.Random(CType(System.DateTime.Now.Ticks Mod System.Int32.MaxValue, Integer))

    Public Function Rand(ByVal Min As Integer, ByVal Max As Integer) As Integer

        Return RandomGen.Next(Min, Max)
    End Function

#End Region
#Region "Logging Code"
    Public LogStream As IO.FileStream
    Public LogFile As String = Date.Now.Day & "-" & Date.Now.Month & "-" & Date.Now.Year

    Public Sub Log(ByVal Title As String, ByVal Message As String, Optional ByVal NewStart As Integer = 0)
        Dim LogData As String

        If Config.EnableLogging = True Then

            If NewStart = 1 Then
                LogData = vbCrLf & vbCrLf
                Dim data1() As Byte = ASCII.GetBytes(LogData)
                LogStream.Write(data1, 0, data1.Length)
                LogStream.Flush()
                LogData = ""
            End If

            LogData = "[" & Date.Now & "] " & Title & ": " & Message & vbCrLf

            Dim data() As Byte = ASCII.GetBytes(LogData)
            LogStream.Write(data, 0, data.Length)
            LogStream.Flush()
            LogData = ""
        End If
    End Sub

#End Region
#Region "Integer Manipulation"

    Public Function MakeInt16(ByVal LoByte As Byte, ByVal HiByte As Byte) As Int16
        Dim Output As Int32
        Output = ((HiByte * &H100) + LoByte)
        If Output > 32767 Then
            Output = (-1) * (65536 - Output)
        End If
        MakeInt16 = Output
    End Function

    Public Function Make1Int16(ByVal LoByte As Byte, ByVal HiByte As Byte) As Int64
        Dim Output As Int64
        Output = ((HiByte * &H100) + LoByte)
        Make1Int16 = Output
    End Function

#End Region
#Region "GetByteCount"

    Public Function GetByteCount(ByVal Bytes() As Byte) As Integer
        If Bytes.Length = 0 Then Exit Function
        Dim i, h As Integer
        h = 10241

        For i = 0 To 10241
            h -= 1
            If Bytes(h) <> 0 Then
                Return h
            End If
        Next i
    End Function

#End Region
End Module

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -