格式转换

qw12380 2003-10-21 11:16:31
text1.text='20030101'
如何将它转换成2003-01-01这种格式
...全文
88 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yjch 2003-10-21
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Dim a(100)
Dim str, b As String
j = Len(Text1.Text)
b = Text1.Text
For i = 1 To j
a(i) = Mid(b, i, 1)
str = str & a(i)
If i = 4 Then
str = str & "-"
End If
If i = 6 Then
str = str & "-"
End If
Next
Text2.Text = str
End Sub
'当在"Text1box1"中输入"20030201"是,在"Textbox2"中可以得到你要的结果........
海牛 2003-10-21
  • 打赏
  • 举报
回复
Private Sub Form_Load()
MsgBox Format("20030101", "####-##-##")
End Sub
海牛 2003-10-21
  • 打赏
  • 举报
回复
Private Function GetDate(ByVal strS As String) As String
Dim strY As String, strM As String, strD As String

strY = Mid$(strS, 1, 4)
strM = Mid$(strS, 5, 2)
strD = Mid$(strS, 7, 2)
GetDate = strY & "-" & strM & "-" & strD
End Function

Private Sub Form_Load()
MsgBox GetDate("20030101")
End Sub
zhangqs 2003-10-21
  • 打赏
  • 举报
回复
直接用
format("20030101","YYYY-MM-DD")即可
northwolves 2003-10-21
  • 打赏
  • 举报
回复
format(DateSerial(Mid("20030101", 1, 4), Mid("20030101", 5, 2), Mid("20030101", 7, 2)),"yyyy-mm-dd")
wang7655 2003-10-21
  • 打赏
  • 举报
回复
什么意思?

转换为日期格式?

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧