以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [讨论]循环语句怎么写?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=127391)

--  作者:cqlwsam
--  发布时间:2018/11/13 8:26:00
--  [讨论]循环语句怎么写?
如题:

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

--  作者:有点甜
--  发布时间: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