- This topic has 21 replies, 5 voices, and was last updated 17 years ago by BattleStar-Galactica.
-
AuthorPosts
-
May 8, 2007 at 6:41 pm #187906methodMember
could any one show me how i can add clock timer that shows hour:min:seconds to a perticuler listview column ?
May 9, 2007 at 2:32 am #187927BattleStar-GalacticaMemberuse paint to draw what you want for that, I didn’t get it because my poor english vocabulary
btw you can find the formula convert second to hour format hh:mm:ss
May 12, 2007 at 5:51 am #187926methodMemberlol.What paint? could you show me a vb6 code?
May 13, 2007 at 12:25 pm #187925sk8erMemberlistview1.text = time?
May 13, 2007 at 4:53 pm #187924methodMemberI mean running timer not just time!!! without any flicking!!
see the clip and you will know what i am looking for
May 14, 2007 at 1:33 am #187923BattleStar-GalacticaMembernow is clear
but think with me to arrive that result, want you?
first we need a timer(because vb6) to get datetime every second
when we get a total seconds and want to display as format hh:mm:ss
do some thing like this
Dim lHrs As Long
Dim lMinutes As Long
Dim lSeconds As Long
lSeconds = 150 '<<<for this example purpose we put 150 seconds
lHrs = Int(lSeconds / 3600)
lMinutes = (Int(lSeconds / 60)) - (lHrs * 60)
lSeconds = Int(lSeconds Mod 60)and now format it to the format as we needed hh:mm:ss
yourresulthere = Format$(lHrs,"00") & ":" & Format$(lMinutes,"00") & ":" & Format$(lSeconds,"00")
[Ghost’s edit] OMG OMG OMG! USE TEH VB TAGS! THAT’S WHAT THEY’RE THERE FOR! [/Ghost’s edit]
May 14, 2007 at 4:11 am #187922methodMemberBattleStar-Galactica Thanks for trying to help me. should i put all these inside a timer? could you explain to me how to make this running on a listview? I hope this a method with no flicker as shown in video . Because i don’t want my other listview data get disturbed by reload of every second. Is this flicker free method?
How to make it start from 00:00:00 and go upward just like stop watch ?
May 14, 2007 at 5:07 am #187921BattleStar-GalacticaMemberthis line >> lSeconds = 150 ‘<<<for this example purpose we Put 150 seconds
to lSeconds = 0
you will get 00:00:00
for free flicker call DoEVents method in vb6. I’m not sure about the exact function name but something like that
I think colo can give you a hand cuz he sleep and eat with vb, i’m not.
May 14, 2007 at 5:16 am #187920methodMemberI placed you code inside timer and it never runs. It stays at 00:00:00!!
Dim lHrs As Long
Dim lMinutes As Long
Dim lSeconds As Long
lSeconds = 0 '<<<for this example purpose we Put 150 seconds
lHrs = Int(lSeconds / 3600)
lMinutes = (Int(lSeconds / 60)) - (lHrs * 60)
lSeconds = Int(lSeconds Mod 60)
'yourresulthere = Format$(lHrs,"00") & ":" & Format$(lMinutes,"00") & ":" & Format$(lSeconds,"00")
ListView1.ListItems(1).ListSubItems(1).Text = Format$(lHrs, "00") & ":" & Format$(lMinutes, "00") & ":" & Format$(lSeconds, "00")I even placed a msgbox at the end timer and saw that timer is actually running but the timer is not!!
May 14, 2007 at 5:21 am #187919BattleStar-GalacticaMemberincrement lSeconds variable like this lSeconds = lSeconds + 1
ah you have to put lSeconds in global if you want to keep it value
post your project here I can check it for uMay 14, 2007 at 5:32 am #187918methodMemberHere is the project. I created a modul and declared lSeconds as shown but still didn’t work!!
Modul:
Option Explicit
'i am declaring varibles that be avalible every where
Public lSeconds As IntegerPrivate Sub Form_Load()
Dim itmx As ListItem
Dim colx As ColumnHeader
'Add Some Columns
Set colx = ListView1.ColumnHeaders.Add(, , "Col1")
Set colx = ListView1.ColumnHeaders.Add(, , "Col2")
'Add two items
Set itmx = ListView1.ListItems.Add(, , "ABC")
itmx.SubItems(1) = "XYZ"
Set itmx = ListView1.ListItems.Add(, , "XYZ")
itmx.SubItems(1) = "ABC"
'Set the view to report
ListView1.View = lvwReport
Timer1.Interval = 1000 ' <-- 10 seconds
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim lHrs As Long
Dim lMinutes As Long
Dim lSeconds As Long
'lSeconds = lSeconds + 1
lSeconds = 0 '<<<for this example purpose we Put 150 seconds
lSeconds = lSeconds + 1
lHrs = Int(lSeconds / 3600)
lMinutes = (Int(lSeconds / 60)) - (lHrs * 60)
lSeconds = Int(lSeconds Mod 60)
'yourresulthere = Format$(lHrs,"00") & ":" & Format$(lMinutes,"00") & ":" & Format$(lSeconds,"00")
ListView1.ListItems(1).ListSubItems(1).Text = Format$(lHrs, "00") & ":" & Format$(lMinutes, "00") & ":" & Format$(lSeconds, "00")
'MsgBox "test"
End SubMay 14, 2007 at 6:15 am #187917BattleStar-GalacticaMemberdelete this line >> lSeconds = 0 ‘<<<for this example purpose we Put 150 seconds
that line is just to initialize lSecond to 0. I see you put alway lSecond to 0 on timer function
May 14, 2007 at 6:50 pm #187916autopilotMemberPlease note: the example below is done in vb2005… may need slight mod to use in vb6
maybe try these as global dim:
Dim hour As Integer = 0
Dim min As Integer = 0
Dim sec As Integer = 0
Dim s As String = "00"
Dim m As String = "00"
Dim h As String = "00"add timer to project and set it to enabled and an interval of 1000 (1 second) and then the following code for the timer:
sec += 1
Select Case sec
Case Is Less Than 10
s = "0" & sec.ToString
Case Is > 59
sec = 0
min += 1
s = "00"
Case Else
s = sec.ToString
End Select
Select Case min
Case Is < 10
m = "0" & min.ToString
Case Is Greater Than 59
min = 0
hour += 1
m = "00"
Case Else
m = min.ToString
End Select
Select Case hour
Case Is < 10
h = "0" & hour.ToString
Case Else
h = hour.ToString
End Select
ListView1.Items.Item(0).Text = String.Format("{00}:{01}:{02}", h, m, s)autopilot
EDIT: The were being read as xml code and changing the post… replace Less Than and Greater Than with apropriate symbol…
May 14, 2007 at 7:23 pm #187915AdminAdministratorYAYS FOR TEH VB TAG!
/me has nothing useful to contribute to this topic…
May 14, 2007 at 8:14 pm #187914methodMemberBattleStar-Galactica i comment out lSeconds =0 but timer never increments!!!
autopilot i wish i had visual basic 2005 edtion. So i don’t know how to modify it for vb6!!!
-
AuthorPosts
Related
- You must be logged in to reply to this topic.