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

📄 frmmain.ebf

📁 evb复制文件到PDA源码
💻 EBF
📖 第 1 页 / 共 2 页
字号:
      Appearance      =   1
      BackColor       =   12632256
      Caption         =   "Read Data"
      Enabled         =   -1  'True
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Style           =   0
   End
   Begin VBCE.TextBox txtRead 
      Height          =   915
      Left            =   3480
      TabIndex        =   11
      Top             =   1140
      Width           =   3315
      _cx             =   5847
      _cy             =   1614
      Appearance      =   1
      BackColor       =   -2147483643
      BorderStyle     =   1
      Enabled         =   -1  'True
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   -2147483640
      Text            =   ""
      Alignment       =   0
      HideSelection   =   -1  'True
      Locked          =   0   'False
      MaxLength       =   0
      MultiLine       =   -1  'True
      PasswordChar    =   ""
      ScrollBars      =   2
   End
   Begin VBCE.Label Label2 
      Height          =   255
      Left            =   60
      TabIndex        =   4
      Top             =   840
      Width           =   1335
      _cx             =   2355
      _cy             =   450
      Appearance      =   1
      AutoSize        =   0   'False
      BackColor       =   -2147483633
      BackStyle       =   1
      BorderStyle     =   0
      Caption         =   "Data to Write:"
      Enabled         =   -1  'True
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   -2147483640
      Alignment       =   0
      UseMnemonic     =   -1  'True
      WordWrap        =   0   'False
   End
   Begin VBCE.TextBox txtData 
      Height          =   915
      Left            =   60
      TabIndex        =   3
      Top             =   1140
      Width           =   3315
      _cx             =   5847
      _cy             =   1614
      Appearance      =   1
      BackColor       =   -2147483643
      BorderStyle     =   1
      Enabled         =   -1  'True
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   -2147483640
      Text            =   "Hello"
      Alignment       =   0
      HideSelection   =   -1  'True
      Locked          =   0   'False
      MaxLength       =   0
      MultiLine       =   -1  'True
      PasswordChar    =   ""
      ScrollBars      =   2
   End
   Begin VBCE.Label Label1 
      Height          =   255
      Left            =   60
      TabIndex        =   2
      Top             =   60
      Width           =   915
      _cx             =   1614
      _cy             =   450
      Appearance      =   1
      AutoSize        =   0   'False
      BackColor       =   -2147483633
      BackStyle       =   1
      BorderStyle     =   0
      Caption         =   "File Name"
      Enabled         =   -1  'True
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   -2147483640
      Alignment       =   0
      UseMnemonic     =   -1  'True
      WordWrap        =   0   'False
   End
   Begin VBCE.TextBox txtFileName 
      Height          =   315
      Left            =   60
      TabIndex        =   1
      Top             =   360
      Width           =   3315
      _cx             =   5847
      _cy             =   556
      Appearance      =   1
      BackColor       =   -2147483643
      BorderStyle     =   1
      Enabled         =   -1  'True
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   -2147483640
      Text            =   "TestFile.txt"
      Alignment       =   0
      HideSelection   =   -1  'True
      Locked          =   0   'False
      MaxLength       =   0
      MultiLine       =   0   'False
      PasswordChar    =   ""
      ScrollBars      =   0
   End
   Begin VBCE.CommandButton cmdWrite 
      Height          =   435
      Left            =   180
      TabIndex        =   0
      Top             =   3300
      Width           =   1995
      _cx             =   3519
      _cy             =   767
      Appearance      =   1
      BackColor       =   12632256
      Caption         =   "Write Data"
      Enabled         =   -1  'True
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Style           =   0
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Function WriteString(MyString As String) As Boolean
    Dim lWritten As Long
    Dim flag As Long
    Dim hFile As Long
    
    If optOverwrite Then
        flag = CREATE_ALWAYS
    Else
        flag = OPEN_ALWAYS
    End If
    
    hFile = CreateFile(txtFileName.Text, GENERIC_READ + GENERIC_WRITE, _
                       0, 0, flag, 0, 0)
    
    If optAppend.Value Then
        SetFilePointer hFile, 0, 0, FILE_END
    End If
    
    If hFile <> -1 Then
        WriteFile hFile, MyString, LenB(MyString), lWritten, 0
        CloseHandle hFile
    End If
End Function

Private Function UnicodeToAnsi(WideString As String) As String
    Dim i As Integer
    
    For i = 1 To LenB(WideString) Step 2
        UnicodeToAnsi = UnicodeToAnsi & MidB(WideString, i, 1)
    Next
End Function


Private Sub cmdBinary_Click()
    Dim data As Integer
    Dim i As Integer
    Dim outbuffer As String
    
    ' binary data (in hex) will be: 42494E4152592044415441
    data = Array(&H42, &H49, &H4E, &H41, &H52, &H59, &H20, &H44, &H41, &H54, &H41)
    
    ' turn binary data into a string
    For i = 0 To UBound(data) - 1
        outbuffer = outbuffer & ChrB(data(i))
    Next
    
    WriteString outbuffer
End Sub

Private Sub cmdRead_Click()
    Dim hFile As Long
    Dim FileSize As Long
    Dim Contents As String
    Dim dwRead As Long
    Dim i As Integer
    Dim output As String
    
    ' get file size
    hFile = CreateFile(txtFileName.Text, GENERIC_READ + GENERIC_WRITE, _
                       0, 0, OPEN_EXISTING, 0, 0)

    If hFile <> -1 Then
        FileSize = GetFileSize(hFile, 0)
        
        
        If FileSize > 0 Then
            ' allocate space for contents
            Contents = String(FileSize, 0)
            
            ' get contents
            ReadFile hFile, Contents, FileSize, dwRead, 0
            
            ' display contents
            If optASCII.Value Then
                txtRead.Text = Contents
            Else
                For i = 1 To FileSize
                    output = output & Right("0" & Hex(AscB(MidB(Contents, i, 1))) & " ", 3)
                Next i
                
                txtRead.Text = output
            End If
        End If
        
        CloseHandle hFile
    End If
End Sub

Private Sub cmdWrite_Click()
    If optANSI.Value Then
        WriteString UnicodeToAnsi(txtData.Text)
    Else
        WriteString txtData.Text
    End If
End Sub

⌨️ 快捷键说明

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