[RESOLVED] MSFlexGrid & Times
Hey Guys, I'm using MSFlexGrid as the title suggests.
This one has had be stumped for some time, and not real sure on how to approach it as MSFlexGrid has querks of its own.
I have times that need to be entered, they go in the format of
mm:ss not really using hours or any type of dates. Hours can be optional, would like to add that in so finally it would be hh:mm:ss but would like the sequence as 0:00 which is the default.
I have two "time" collumns. Then finally a totals column which adds the two together. My question is how to do this error free. I keep comming up with wierd numbers, and don't know if I'm exactly calling the thing right.
Second Q: I'm using the mod that puts a floating textbox above the flex-grid. Question is, can I make it change on just those 3 columns (I have other stringed columns) to make it do a insert type thing, so pressing the number 1 will from the right update it to 0:01 then typing in #0 will make 0:10
Thanks fellow bretherans for the help with the code. THe software I'm developing is coming along very fine! Gotta love VB.
Re: [RESOLVED] MSFlexGrid & Times
You should also format the values inside the CDate (as I did), to ensure that the values are converted to times accurately.
Quote:
but then yours had an error
:confused:
Re: [RESOLVED] MSFlexGrid & Times
I recieved a type mismatch error, if memory serves correct.
Re: [RESOLVED] MSFlexGrid & Times
I've just checked my code and can't see anything obvious, so I would assume that the values could not be converted into times.
Therefore I would recommend using a bit of validation, possibly like this:
VB Code:
Dim sTime as String
Dim sTempTime as String
With MSFlexGrid1
sTime = "0:00:00"
sTempTime = Format$(.TextMatrix(r, firstcol),"####0:00:00")
If IsDate(sTempTime) Then sTime = sTime + CDate(sTempTime)
sTempTime = Format$(.TextMatrix(r, secondcol),"####0:00:00")
If IsDate(sTempTime) Then sTime = sTime + CDate(sTempTime)
If Left$(sTime,2) = "::" Then sTime = Mid$(sTime,2)
.TextMatrix(r, totalcol) = sTime
End With
If you still get an error, you should let me know which line it occurs on, and what the text values are.