Foxtable(狐表)用户栏目专家坐堂 → [讨论]循环语句怎么写?


  共有1933人关注过本帖树形打印复制链接

主题:[讨论]循环语句怎么写?

帅哥哟,离线,有人找我吗?
cqlwsam
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1022 积分:7598 威望:0 精华:0 注册:2010/4/12 12:23:00
[讨论]循环语句怎么写?  发帖心情 Post By:2018/11/13 8:26:00 [只看该作者]

如题:

如:从M201到N371,怎么写循环语句?

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/11/13 8:54:00 [只看该作者]

1、逻辑是什么?循环都999以后字母加1?

 

2、参考代码

 

Dim s1 As String = "M201"
Dim s2 As String = "N371"
Dim a1 = Asc(s1.Substring(0,1))
Dim a2 = Asc(s2.Substring(0,1))
For i As Integer = a1 To a2
    If i = a1 Then
        If a1 = a2 Then
            For j As Integer = s1.SubString(1) To s2.Substring(1)
                output.show(chr(i) & Format(j, "000"))
            Next
        Else
            For j As Integer = s1.SubString(1) To 999
                output.show(chr(i) & Format(j, "000"))
            Next
        End If
    ElseIf i = a2 Then
        For j As Integer = 1 To s2.SubString(1)
            output.show(chr(i) & Format(j, "000"))
        Next
    Else
        For j As Integer = 1 To 999
            output.show(chr(i) & Format(j, "000"))
        Next
    End If
Next


 回到顶部