vb怎么给这种时间做加法,比如:00:13:13,496给加上00:13:20,287?DateAdd好像没法加毫秒的吧?
本帖最后由 wnujy611861 于 2013-03-05 18:40:43 编辑 最近学英语,在有土鳖上下了好多字幕,它那个字幕是分为n段的,我想把这n段字幕合并成一个,第二个的时间轴直接加上第一个的末尾的时间.找了下现成的软件都只能合并2个的,麻烦死了.
比如下面这个,我要所有的时间都加上00:13:20,287 要怎么弄呢?也就是从个例上说比如:00:13:13,496给加上00:13:20,287要怎么算法呢?DateAdd好像没法加毫秒的吧?多谢!! 话说告诉大家一个小秘密,有土鳖超强,你传视频上去它会自动给你语音识别给配上字幕,连时间轴都帮你做好了,准确率那是相当的高...有看美剧没字幕的大家往上传.....
197
00:13:12,496 --> 00:13:13,496
It' s really very simple.
198
00:13:14,080 --> 00:13:15,080
Is there a problem?
199
00:13:15,879 --> 00:13:16,879
Aren' t you happy here?
200
00:13:19,287 --> 00:13:20,287
Yes. But I would like to know what plans you have for me.
Option Explicit
Private Sub Command1_Click()
Debug.Print TimeAdd("00:13:13,496", "00:13:20,287")
End Sub
Public Function TimeAdd(ByVal strTime1 As String, ByVal strTime2 As String) As String
Dim tmp() As String
Dim strHMS1 As String, strHMS2 As String
Dim intMS1 As Integer, intMS2 As Integer
Dim datResult As Date
On Error GoTo exitfunction
tmp = Split(strTime1, ",")
strHMS1 = tmp(0)
If UBound(tmp) = 1 Then
intMS1 = CInt(tmp(1))
End If
tmp = Split(strTime2, ",")
strHMS2 = tmp(0)
If UBound(tmp) = 1 Then
intMS2 = CInt(tmp(1))
End If
datResult = CDate(strHMS1) + CDate(strHMS2)
intMS1 = intMS1 + intMS2
If (intMS1 >= 1000) Then
datResult = datResult + CDate("00:00:01")
intMS1 = intMS1 - 1000
End If
exitfunction:
TimeAdd = Format(datResult, "HH:nn:ss") & "," & CStr(intMS1)
End Function