vb 读取文本写入excel

来源:百度知道 编辑:UC知道 时间:2024/06/10 02:10:53
读取文本,逐行判断譬如 1 a
2 b
sjdlafj;fdas
3 c
先判断该行是否有1 无判断是否有2 如果有 读取该行后面的几个字符,然后写入excel中,写入excel我会点 这个逐行读取判断不会,高手请指教
也加上写入excel吧 我会在追加50分

Private Sub Command1_Click() Dim s1() As String, s2() As String, s3() As String, s4() As String Container = find("Container:.+\b", RichTextBox1) ContainerType = find("Container Type:\s+\S+", RichTextBox1) ContractNumber = find("Contract Number:.+\b", RichTextBox1) ContractType = find("Contract Type:.+\b", RichTextBox1) Text3 = Container & vbNewLine & ContainerType & vbNewLine & ContractNumber & vbNewLine & ContractType s1 = Split(Container, "Container: ") s2 = Split(ContainerType, "Container Type: ") s3 = Split(ContractNumber, "Contract Number: ") s4 = Split(ContractType, "Contract Type: ") '你只要将数组中元素赋值到相应表格即 Dim t As Integer Dim appexcel As Object '定义Excel应用程序对象 Dim wbmybook As Object '定义工作簿对象 Dim wsmysheet As Object '定义工作表对象 Set appexcel = CreateObject("excel.application") '创建Excel应用程序对象 Set wbmybook = appexcel.Workbooks.Add '添加工作簿 Set wsmysheet = a