以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]字符串的格式化问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=85355)

--  作者:舟舟
--  发布时间:2016/5/24 0:33:00
--  [求助]字符串的格式化问题
有一个字符串,格式为:160523-193127,我想把它格式化为16年05月23日19时31分27秒。我能想到的办法,是利用Substring来实现,但比较复杂些。有没有更简单的办法?使用Format可以实现吗?
--  作者:Hyphen
--  发布时间:2016/5/24 8:48:00
--  
Dim s As String = "160523-193127"
s = s.Replace("-","日").Insert(11,"分").Insert(9,"时").Insert(4,"月").Insert(2,"年") & "秒"
Output.Show(s)

--  作者:舟舟
--  发布时间:2016/5/24 14:15:00
--  
以下是引用Hyphen在2016/5/24 8:48:00的发言:
Dim s As String = "160523-193127"
s = s.Replace("-","日").Insert(11,"分").Insert(9,"时").Insert(4,"月").Insert(2,"年") & "秒"
Output.Show(s)


牛 B ,谢谢!