提取textbox最优的办法,并进行运算!

作者在 2009-11-15 22:25:36 发布以下内容
我的调入代码是
 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim f As System.IO.FileStream
        Dim r As System.IO.StreamReader
        Dim vt, maohao, yinghao, kongge, fenhao As String
        f = New System.IO.FileStream(TextBox1.Text, FileMode.Open, FileAccess.Read)
        r = New System.IO.StreamReader(f)
        vt = r.ReadToEnd
        maohao = Replace(vt, vbTab, "")
        yinghao = Replace(maohao, Chr(34), "")
        kongge = Replace(yinghao, " ", "")
        fenhao = Replace(kongge, ";", "")
        Form2.TextBox1.Text = Replace(fenhao, ":", "")
        Form2.Show()
        Me.Hide()
    End Sub
运算代码是
   Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        TextBox2.Text = ""
        Dim arry1(,) As String
        Dim arry2() As String
        Dim I As Integer, j As Integer
        Dim intTmp1 As Integer, intTmp2 As Integer
        intTmp1 = TextBox1.Lines.GetUpperBound(0)
        arry2 = Split(Trim(TextBox1.Lines(0)), ",")
        intTmp2 = arry2.GetUpperBound(0)
        ReDim Preserve arry1(intTmp1, intTmp2)
        For I = 0 To intTmp1 - 1
            arry2 = Split(Trim(TextBox1.Lines(I)), ",")
            For j = 0 To intTmp2 - 1
                arry1(I, j) = arry2(j)
            Next
            TextBox2.Text = TextBox2.Text + arry1(I, 1) + "," + arry1(I, 5) + "," + arry1(I, 2) + "," + arry1(I, 3) + "," + arry1(I, 4) + vbCrLf
        Next
    End Sub
我的结果就是将一个txt的文本里像
300007,D1,430783.471217,2798624.472971,153.289831,,06-10-2009/081434.0,MEAS
300008,D2,430780.312605,2798629.897780,153.223091,,06-10-2009/081503.0,MEAS
300009,D3,430762.522724,2798639.359567,153.241870,,06-10-2009/081531.0,MEAS
300010,D4,430778.304664,2798626.194055,153.137028,,06-10-2009/081612.0,MEAS
300011,D5,430776.054516,2798624.890176,153.036815,,06-10-2009/081634.0,MEAS
300012,D6,430774.715683,2798624.311983,153.060566,,06-10-2009/081838.0,MEAS
300013,D7,430751.554418,2798646.430697,153.224378,,06-10-2009/082028.0,MEAS
这样的数据转换成
D1,,430783.471217,2798624.472971,153.289831
D2,,430780.312605,2798629.897780,153.223091
D3,,430762.522724,2798639.359567,153.241870
D4,,430778.304664,2798626.194055,153.137028
D5,,430776.054516,2798624.890176,153.036815
D6,,430774.715683,2798624.311983,153.060566
D7,,430751.554418,2798646.430697,153.224378
我的程序可以运行,就是感觉数据多的话有点慢,想请问一下又没有更好的运算方法啊?
 
问题 | 阅读 493 次
文章评论,共0条
游客请输入验证码
文章分类
文章归档
最新评论