| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1279 人关注过本帖
标题:变量s中的0-9为什么没有被替换,如何改?
只看楼主 加入收藏
yuma
Rank: 12Rank: 12Rank: 12
来 自:银河系
等 级:贵宾
威 望:37
帖 子:1934
专家分:3012
注 册:2009-12-22
结帖率:89.13%
收藏
 问题点数:0 回复次数:4 
变量s中的0-9为什么没有被替换,如何改?
变量s中的0-9为什么没有被替换,如何改?

程序代码:
Private Sub Form_Load()
Dim s As String
s = "73203d2022d6d0bbaac"
For i = 1 To Len(s)
a = Mid(s, i, 1)
a = Replace(a, "0", "f")
a = Replace(a, "1", "e")
a = Replace(a, "2", "d")
a = Replace(a, "3", "c")
a = Replace(a, "4", "b")
a = Replace(a, "5", "a")
a = Replace(a, "6", "9")
a = Replace(a, "7", "8")
a = Replace(a, "8", "7")
a = Replace(a, "9", "6")
a = Replace(a, "a", "5")
a = Replace(a, "b", "4")
a = Replace(a, "c", "3")
a = Replace(a, "d", "2")
a = Replace(a, "e", "1")
a = Replace(a, "f", "0")
b = b & a
Next
Debug.Print b
End Sub
搜索更多相关主题的帖子: 变量 替换 Replace Sub Next 
2021-08-26 21:20
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4947
专家分:30084
注 册:2008-10-15
收藏
得分:0 
a = Replace(a, "0", "f")
0变成了f
然后最后
a = Replace(a, "f", "0")
f又变成了0了,包括原来的f都变成了0
最终,0 还是 零,f变成了0
所以,最终是 0-7没变,8-f都变了。

----------------------------
换的过程应该是,每二个一组交换,交换需要引入新的字符
程序代码:
'---0 f ----
a = Replace(a, "0", "s")
a = Replace(a, "f", "0")
a = Replace(a, "s", "f")
'---1 e ----
a = Replace(a, "1", "s")
a = Replace(a, "e", "1")
a = Replace(a, "s", "e")
........





授人于鱼,不如授人于渔
早已停用QQ了
2021-08-26 22:29
yuma
Rank: 12Rank: 12Rank: 12
来 自:银河系
等 级:贵宾
威 望:37
帖 子:1934
专家分:3012
注 册:2009-12-22
收藏
得分:0 
s = "73203d2022d6d0bbaac"
For i = 1 To Len(s)
a = Mid(s, i, 1)
If a = "0" Then b = "f"
If a = "1" Then b = "e"
If a = "2" Then b = "d"
If a = "3" Then b = "c"
If a = "4" Then b = "b"
If a = "5" Then b = "a"
If a = "6" Then b = "9"
If a = "7" Then b = "8"
If a = "8" Then b = "7"
If a = "9" Then b = "6"
If a = "a" Then b = "5"
If a = "b" Then b = "4"
If a = "c" Then b = "3"
If a = "d" Then b = "2"
If a = "e" Then b = "1"
If a = "f" Then b = "0"
c = c & b
Next
MsgBox c

[此贴子已经被作者于2021-11-29 13:43编辑过]


心生万象,万象皆程序!
本人计算机知识网:http://bbs.为防伸手党,本站已停止会员注册。
2021-08-27 06:16
cwa9958
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:76
帖 子:279
专家分:1367
注 册:2006-6-25
收藏
得分:0 
用select case语句会好看点。
2021-08-30 08:38
apull
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:三体星系
等 级:版主
威 望:216
帖 子:1507
专家分:9241
注 册:2010-3-16
收藏
得分:0 
程序代码:
Private Sub Form_Load()
    Dim s As String
    s = "73203d2022d6d0bbaac"
    For i = 1 To Len(s)
        a = Mid(s, i, 1)
        If (a >= "0" And a <= "5") Then
            a = Chr(Asc("f") - (Asc(a) - Asc("0")))
        ElseIf (a >= "6" And a <= "9") Then
            a = Chr(Asc("9") - (Asc(a) - Asc("6")))
        ElseIf (a >= "a" And a <= "f") Then
            a = Chr(Asc("5") - (Asc(a) - Asc("a")))
        End If
        b = b & a
    Next
    Debug.Print b
End Sub
2021-08-30 10:16
快速回复:变量s中的0-9为什么没有被替换,如何改?
数据加载中...
 
   



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

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