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

📄 mstring.bas

📁 需要控件:Active Report 2.0(专业报表控件破解版)2.0下的ardespro2.dll和arpro2.dll ARVIEW2.OCX等文件。即可打开源代码。
💻 BAS
字号:
Attribute VB_Name = "mString"
Option Explicit

Public Function PadSpaces(strField As String, NeededSize As Integer, Jstf As Integer) As String
    '1 = 居左
    '2 = 居右
    '3 = 居中
    '05-06-28 发现问题信息太长无法排列
    On Error Resume Next
    Dim valDesiredLength As Long
    Dim valCurrentLength As Long
    Dim valAmount As Long
    Dim nAmount As Long
    strField = Trim(strField)
    valCurrentLength = LenB(strField)
    valDesiredLength = NeededSize

    If Jstf = 1 Then
        If valCurrentLength <> valDesiredLength Then
            valAmount = valDesiredLength - valCurrentLength
            strField = strField & Space(valAmount)
        End If
    ElseIf Jstf = 2 Then
        If valCurrentLength <> valDesiredLength Then
            valAmount = valDesiredLength - valCurrentLength
            'XXXXXXXXXXXXXXXXXXXX
            strField = Space(valAmount) & strField
        End If
    ElseIf Jstf = 3 Then
        If valCurrentLength <> valDesiredLength Then
            valAmount = valDesiredLength - valCurrentLength
            nAmount = valAmount \ 2
            strField = Space(nAmount) & strField
            strField = strField & Space(nAmount)
        End If
    End If
    PadSpaces = strField
End Function


Public Function align(ByVal strInstring As String, _
    ByVal lngAlignLength As Long, _
    Optional ByVal strAlign As String = "LEFT", _
    Optional ByVal strFill As String = " ") As String
    '
    ' Align and fill a string
    '
    '
    Dim bytModulus As Byte
    Dim lngSizeDelta As Long
    Dim strAligned As String


    Select Case Trim$(UCase$(strAlign))
        Case "LEFT":
        strAligned = Mid$(strInstring, 1, lngAlignLength)
        Case "RIGHT":
        strAligned = Right$(strInstring, lngAlignLength)
        Case "CENTER":
        strAligned = Mid$(strInstring, 1, lngAlignLength)
        Case Else:
        MsgBox "Invalid align code " & strAlign
    End Select


If Len(strFill) <> 1 Then
    MsgBox "Fill is Not one character"
Else
    lngSizeDelta = lngAlignLength - LenB(strInstring)


    If lngSizeDelta > 0 Then


        If strAlign = "LEFT" Then
            strAligned = strInstring & String$(lngSizeDelta, strFill)
        ElseIf strAlign = "RIGHT" Then
            strAligned = String$(lngSizeDelta, strFill) & strInstring
        Else
            bytModulus = lngSizeDelta Mod 2
            lngSizeDelta = lngSizeDelta \ 2
            strAligned = String$(lngSizeDelta, strFill) & _
            strInstring & _
            String$(lngSizeDelta + bytModulus, strFill)
        End If
    End If
End If
align = strAligned
End Function


'检测所含字符中的汉字
Public Function convert_string(mystring As String) As String
Dim i As Integer
Dim temp_string As String
    temp_string = ""
    For i = 0 To Len(mystring) - 1
       If Asc(Mid(mystring, i + 1, 1)) < 0 Or Asc(Mid(mystring, i + 1, 1)) > 64 Then
             temp_string = temp_string & Mid(mystring, i + 1, 1)
       End If
    Next
    convert_string = temp_string
End Function

⌨️ 快捷键说明

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