| 网站首页 | 业界新闻 | 群组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 编程论坛
免费IT实战开发视频教程合集分享千里之行 始于足下
共有 151 人关注过本帖
标题:如何改写两个任意数字之间的点成M
只看楼主 加入收藏
ictest
Rank: 2
等 级:论坛游民
帖 子:226
专家分:77
注 册:2010-2-17
结帖率:74.29%
  已结贴   问题点数:5  回复次数:3   
如何改写两个任意数字之间的点成M
一个TXT文件,内容如下:
...........22221237542221111211111111111111111111111112212212222222222.............
..........2222121902211111221222111112111122112222221212112111111112222............
.........71211111....111111111111111111111122...22212121111221111..211121..........
.........111111111....111111111111111111111118...11111111111111111..1211127........
........1111141112....222111111111111211111111...21111211111111111..11111112.......
.......31111131111....112111111111111111111117...11111111111111111..11121113.......
......61111111111....111221121111112111212111...31111111111111111..211111125.......
......411111116111....112211111111111111111114...11111111111111111..111211224......
.....211111111112....121111111111111111111112...81111111111111212..211121128.......
....11111171111113....366111111111111111111116...11111111111111111..111111221......
....11111111111114231110281111111111111111111111111111111111111112111111121........
....11111111141171587651191111111111111111111111111112111111111111111111111........

现在想把每行中两个数字之间的 . 替换成字母 M ,
两边的 . 不替换,两边的 . 数量也不变,
请教该如何编写这段语句?
2018-11-02 16:03
yingshu
Rank: 2
等 级:论坛游民
威 望:1
帖 子:29
专家分:98
注 册:2018-7-24
  得分:3 
    Dim str As String
    Dim txt As String
   
    Dim i As Integer
    Dim a As Integer, b As Integer, c As Integer
  
    Open "F:\123.TXT" For Input As #1
   
    Do While Not EOF(1)
        Line Input #1, str
            For i = 1 To Len(str)           'for循环判断首数字出现位置并赋值给a
                txt = Mid(str, i, 1)
                If IsNumeric(txt) Then
                   Exit For
                End If
            Next i
            a = i - 1
            b = Len(str)                    '确定字符总长度
            str = Replace(Trim(Replace(str, ".", " ")), " ", "M")  '赋值语句是为了截取中间位置,并替换
            c = Len(str)
            str = String(a, ".") & str & String(b - a - c, ".")
            Text1.Text = Text1.Text + vbNewLine + str   '结果显示
    Loop
2018-11-02 21:59
wds1
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:27
帖 子:262
专家分:1447
注 册:2016-3-10
  得分:3 
Private Sub Command1_Click()
  Open "F:\123.TXT" For Input As #1
  Do While Not EOF(1)
    Line Input #1, txt
    temp = Replace(txt, ".", " ")
    L1 = String(Len(txt) - Len(LTrim(temp)), ".")
    r1 = String(Len(txt) - Len(RTrim(temp)), ".")
    m1 = Replace(Trim(temp), " ", "M")
    temp = L1 & m1 & r1
    Debug.Print temp
  Loop
End Sub
2018-11-03 10:52
yingshu
Rank: 2
等 级:论坛游民
威 望:1
帖 子:29
专家分:98
注 册:2018-7-24
  得分:0 
娘希匹的,熟的不能再熟的熟透了的知识,用时咋就没想起来
向高手致敬,受教了
2018-11-03 11:14







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

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