2哥学Vb.net--随记

前端之家收集整理的这篇文章主要介绍了2哥学Vb.net--随记前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

刚刚在微博上看到的一道题:在vb.net中如何用二维数组逐个的把TEXTBox文本框里面的数字读取?数字如下:

0 1 2 3

1 2 3 4

2 3 4 5

3 4 5 6

参照这个题目,自己写了下代码(先将TEXTBox的MultiLine 勾选)

 Try
            Dim arry1(,) As Integer

            Dim i%,j%

            j = TextBox1.Lines.Count

            For m As Integer = 0 To j - 1

                i = UBound(Split(TextBox1.Lines(m)," "))

                ReDim Preserve arry1(j,i)

                For n As Integer = 0 To i

                    arry1(m,n) = Split(TextBox1.Lines(m).ToString," ")(n)

                Next
            Next

            'For test
            MsgBox(arry1(3,3))

        Catch ex As Exception

            MessageBox.Show(ex.Message)

        End Try
原文链接:https://www.f2er.com/vb/258904.html

猜你在找的VB相关文章