标题:请教各位怎么循环数组
只看楼主
qinyi92
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2019-9-23
 问题点数:0 回复次数:2 
请教各位怎么循环数组
刚开始学习,请教各位大佬怎么循环数组
A1*1后面怎么多出个117,请教各位帮我看一下代码怎么修改

Public Class Form2
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim f As String
        '设置打开的文本格式
        OpenFileDialog1.Filter = "Text Files(*.TXT)|*.TXT"
        If OpenFileDialog1.ShowDialog = DialogResult.OK Then
            f = (OpenFileDialog1.FileName)
            '下面是把文本里的度分秒符号替换,这个是中海达格式
            f = Replace(Trim(f), "°", ",")
            f = Replace(Trim(f), "′", ",")
            f = Replace(Trim(f), "″,", ",")
            Dim f1 As String()
            Dim f2 As Double, f3 As Double, f4 As Double
            Dim f5 As String
            Dim i As Integer, i1 As Integer
            For i = 0 To f.Length
                f1 = f.Split(",")
                f2 = Val(f1(0) + f1(1) / 60 + f1(2) / 3600)
                f3 = Val(f1(3) + f1(4) / 60 + f1(5) / 3600)
                f4 = Val(f1(6))
                f5 = f1(7)
                TextBox1.Text = f2
                'TextBox2.Text = f3
                DataGridView1.Rows.Add(f2, f3, f4, f5)
            Next

        End If
搜索更多相关主题的帖子: 数组 Dim 循环 String Text 
2019-10-12 16:18
qinyi92
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2019-9-23
得分:0 
2019-10-12 16:19
ccmirlove
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-12-23
得分:0 
使用这个.getupperbound应该是可以的,不过起始值从1开始,你修改一下你的代码即可。

For i = 0 To f.GetUpperBound(0)
    f1 = f.Split(",")
         f2 = Val(f1(0) + f1(1) / 60 + f1(2) / 3600)
          f3 = Val(f1(3) + f1(4) / 60 + f1(5) / 3600)
          f4 = Val(f1(6))
          f5 = f1(7)
          TextBox1.Text = f2
          'TextBox2.Text = f3
          DataGridView1.Rows.Add(f2, f3, f4, f5)
Next



p.s:中海达,看来大家是同行啊~~
2019-11-08 08:56



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-497224-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.076058 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved