mainmod.bas

来自「用VB调用SSH控件」· BAS 代码 · 共 123 行

BAS
123
字号
Attribute VB_Name = "MainMod"
Public Declare Function StrFormatByteSize Lib "shlwapi" Alias "StrFormatByteSizeA" (ByVal dw As Long, ByVal pszBuf As String, ByRef cchBuf As Long) As String


'加密函数
Public Function Crypt(texti, salasana) As String

       On Error Resume Next

              For T = 1 To Len(salasana)
                     sana = Asc(Mid(salasana, T, 1))
                     X1 = X1 + sana
              Next

       X1 = Int((X1 * 0.1) / 6)
       salasana = X1
       G = 0

              For TT = 1 To Len(texti)
                     sana = Asc(Mid(texti, TT, 1))
                     G = G + 1

                            If G = 6 Then G = 0
                                   X1 = 0

                                          If G = 0 Then X1 = sana - (salasana - 2)

                                                        If G = 1 Then X1 = sana + (salasana - 5)

                                                                      If G = 2 Then X1 = sana - (salasana - 4)

                                                                                    If G = 3 Then X1 = sana + (salasana - 2)

                                                                                                  If G = 4 Then X1 = sana - (salasana - 3)

                                                                                                                If G = 5 Then X1 = sana + (salasana - 5)
                                                                                                                       X1 = X1 + G
                                                                                                                       Crypted = Crypted & Chr(X1)
                                                                                                                Next

                                                Crypt = Crypted
                                                                                                                End Function

'解密函数
Public Function DeCrypt(texti, salasana) As String

       On Error Resume Next

              For T = 1 To Len(salasana)
                     sana = Asc(Mid(salasana, T, 1))
                     X1 = X1 + sana
              Next

       X1 = Int((X1 * 0.1) / 6)
       salasana = X1
       G = 0

              For TT = 1 To Len(texti)
                     sana = Asc(Mid(texti, TT, 1))
                     G = G + 1

                            If G = 6 Then G = 0
                                   X1 = 0

                                          If G = 0 Then X1 = sana + (salasana - 2)

                                                        If G = 1 Then X1 = sana - (salasana - 5)

                                                                      If G = 2 Then X1 = sana + (salasana - 4)

                                                                                    If G = 3 Then X1 = sana - (salasana - 2)

                                                                                                  If G = 4 Then X1 = sana + (salasana - 3)

                                                                                                                If G = 5 Then X1 = sana - (salasana - 5)
                                                                                                                       X1 = X1 - G
                                                                                                                       DeCrypted = DeCrypted & Chr(X1)
                                                                                                                Next


                                                                                                                DeCrypt = DeCrypted
                                                                                                                End Function


'shlwapi.dll is used to get the format of converting bytes
'into bytes, KB, MB and GB
Public Function FormatKB(ByVal Amount As Long) As String
    Dim Buffer As String
    Dim result As String
    Buffer = Space$(255)
    result = StrFormatByteSize(Amount, Buffer, Len(Buffer))
    If InStr(result, vbNullChar) > 1 Then FormatKB = Left$(result, InStr(result, vbNullChar) - 1)
End Function

Public Sub UnloadFormsOpen()
    
    On Error Resume Next
    Unload FrmPrintText
    Unload FrmRemoveDir
    Unload FrmDownload
    Unload FrmCreateDir
    Unload FrmFileBrowse
    Unload FrmBusy
    Unload FrmConnectionInfo
    Unload FrmKeyCtrls
    Unload FrmUpload
    
    'I found out infact that these loaded the forms at first and not unloaded them
    'This was a bad problem because all Form_Load() sub's started in the following forms
    'and lots of silly thing starting happening.
    
'    If FrmPrintText.Visible = True Then Unload FrmPrintText
'    If FrmRemoveDir.Visible = True Then Unload FrmRemoveDir
'    If FrmDownload.Visible = True Then Unload FrmDownload
'    If FrmCreateDir.Visible = True Then Unload FrmCreateDir
'    If FrmFileBrowse.Visible = True Then Unload FrmFileBrowse
'    If FrmBusy.Visible = True Then Unload FrmBusy
'    If FrmConnectionInfo.Visible = True Then Unload FrmConnectionInfo
'    If FrmKeyCtrls.Visible = True Then Unload FrmKeyCtrls
'    If FrmUpload.Visible = True Then Unload FrmUpload
    
End Sub

⌨️ 快捷键说明

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