Link to home
Create AccountLog in
Avatar of MTec89_
MTec89_Flag for United States of America

asked on

VB6 quotes escape

i have a peice of code like this

something = "hey yo "wahh!! more text" yeah yeah..."
 but i cant seem to find an escape charecter so vb ignores the 2 inner quotes, and treats them like normal text in the variable.

also i have a peice of code that states the program's running time, however at midnight it seems to mess up.
form load:
Label1.Caption = Time()

button click:
time1 = Time()
time2 = Label1.Caption
Diff = TimeValue(time2) - TimeValue(time1)
hourdiff = Hour(Diff)
mindiff = Minute(Diff)
secdiff = Second(Diff)
msgbox("" + hourdiff + "hrs " + mindiff + "mins " + secdiff + "secs")
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of MTec89_

ASKER

can you run some datediff code by me so i can see what i need to do to get the time my program has been running?
Avatar of MTec89_

ASKER

also, without luck i was trying to find a function that will format the date as such: Fri, 04 Mar 2005 21:15:18 GMT
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
The following shows the elapsed time your app has been running in Label1.  The code in the buttons shows how to format a date almost like you want.  I'm not sure how you would go about getting the "GMT" part....

Option Explicit

Private startTime As Date

Private Sub Command1_Click()
    MsgBox Format(Now(), "Long Date") & " " & Format(Now(), "Long Time")
End Sub

Private Sub Form_Load()
    startTime = Now
    Timer1.Interval = 333
End Sub

Private Sub Timer1_Timer()
    Dim secs As Long
    Dim mins As Long
    Dim hrs As Long
   
    secs = DateDiff("s", startTime, Now())
           
    hrs = secs \ 3600
    secs = secs - (hrs * 3600)
           
    mins = secs \ 60
    secs = secs - (mins * 60)
           
    Label1.Caption = Format(hrs, "00") & ":" _
        & Format(mins, "00") & ":" & Format(secs, "00")
End Sub
Avatar of MTec89_

ASKER

runtime error '6';
overflow

->     secs = DateDiff("s", startTime, Now())


actually i dont know about the GMT part, it was just there. the date format im trying to match, is that of a HTTP header date.
To display the accumulated running time this may help:

Dim time1 As Date
Dim time2 As Date
Dim dtDiff As Date

time1 = Now()
time2 = #1/1/2005#

dtDiff = time1 - time2

MsgBox "Running time: " & DateDiff("d", time2, time1) & " days + " & Format(dtDiff, "hh:nn:ss")
Avatar of MTec89_

ASKER

well that one seems to be off a bit
62 days + 19:58:53.
Avatar of MTec89_

ASKER

ok i did form load time 1 and when calling the uptime i did time2=now hopefully this will work without bugs.