以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]字符替换 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=191900) |
-- 作者:江南小镇 -- 发布时间:2024/5/14 17:44:00 -- [求助]字符替换 老师好, 我想把“ ”M1","M2","M2","M3","M4","M5","M6"......”替换成 “ "一月","二月","二月","三月","四月","五月","六月"......”
Dim s1() As String = {"M1","M2","M2","M3","M4","M5","M6","M7","M8","M9","M10","M11","M12"} Dim s2() As String = {"一月","二月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"} Dim s As String = "编号|38|年|38|项目ID|118|M1|50|M2|50|M3|50|M4|50|M5|50|M6|50|M7|50|M8|50|M9|50|M10|50|M11|50|M12|50" For i As Integer = 0 To s1.length - 1 s = s.replace("|" & s1(i) & "|", "|" & s2(i) & "|") Next |
-- 作者:有点蓝 -- 发布时间:2024/5/14 20:12:00 -- 代码有啥问题? |
-- 作者:江南小镇 -- 发布时间:2024/5/15 6:56:00 -- 老师好, 没有替换掉。
|
-- 作者:有点蓝 -- 发布时间:2024/5/15 8:34:00 -- 我测试没有问题 |
-- 作者:cd_tdh -- 发布时间:2024/5/15 8:38:00 -- 你是不问过吗? Dim s1()As String = {"M1", "M2", "M3", "M4", "M5", "M6", "M7", "M8", "M9", "M10", "M11", "M12"} Dim s2()As String = {"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月" } Dim s As String = "编号|38|年|38|项目ID|118|M1|50|M2|50|M3|50|M4|50|M5|50|M6|50|M7|50|M8|50|M9|50|M10|50|M11|50|M12|50" For i As Integer = 0 To s1.length - 1 s = s.replace("|" & s1(i) & "|", "|" & s2(i) & "|") Next msgbox(s) |