February 2006

Blog down time!

This bolg was down for a few days last week. I have no idea why, I dont think it was because of hits! I basically I think it was a hosting issue – I’m waiting to hear back from my hosts. I hope this does not become a regular event. Sorry to anyone who tried to get to the site when it was down.

Get back to school!

This is cool.

The ones I have watched have been good, it’s a nice way to learn/recap on some intresting subjects. Be sure to check out the following:

http://webcast.berkeley.edu/courses/archive.php?seriesid=1906978270

http://webcast.berkeley.edu/courses/archive.php?seriesid=1906978271

http://webcast.berkeley.edu/courses/archive.php?seriesid=1906978272

via MarkWielgus.com

Combine Formulas into one cell

Here is some simple code to combine a selction of formulas into one cell. I have not tested it very much so it's not guaranteed. It will also add a few extra (), than might be needed.

Sub CombineFormulas()
Dim objCell As Object
Dim sTemp As String
Dim sOperator As String
Dim rOutPut As range

On Error GoTo errorhandel

sOperator = InputBox("Operator to use?", "CombineFormulas")

For Each cell In Selection
If Len(cell.Cells.Formula)> 1 Then
''get the formula, adds a "(" , remove the "=", add the closing ")", and puts a "+" on the end
sTemp = sTemp & "(" & Right(cell.Cells.Formula, (Len(cell.Cells.Formula) - 1)) & ")" & sOperator
Else
End If
Next

''Puts an "=" at the start, then gets rid of the last "+",
sTemp = "=" & Left(sTemp, Len(sTemp) - 1)

Set rOutPut = Application.InputBox("Put In Cell", Type:=8)

ActiveSheet.range(rOutPut.Address).Formula = sTemp

Exit Sub

errorhandel:
MsgBox "Error: " & vbNewLine _
& Err.Description & vbNewLine _
& Err.Number, _
vbOKOnly, "CombineFormulas"
End Sub

VBA for iG_Syntax_Hiliter

I produced a .php file for VBA. I got most of the "Keywords" from ostrosoft.com, and added a few myself. I also changed the colour system. The VBA file has abou 160 "keywords" vs about 300 for the VB one. This is beacuse the "keywords" are infact "Bluewords", that is to say the code produced by my VBA .php file should be the same as if it where in then VBA IDE (theres green, blue and black and that's it).
vba bluewords .zip

VB timer as Double

Ok so this is a lazy post, but has anyone used the timer with double type?
Try it, I'm looking into this and hope to get a better understanding of the whole thing, but it seems to use 3 decimal places when loading the time, and more when subtacting (more sdp than singles). In documention it says Timer returns a single. Thus i would have thought (FLW!) that if the result was getting put in a double it would return the same result, and maybe add some zeros. But if that's the limit of the timer then the other numbers shouldn't be there - right?

Sub TimerTest()

Dim LongTimer  As Long
Dim VariantTimer As Variant
Dim DoubleTimer As Double
Dim IntegerTimer As Integer
Dim SingleTimer As Single
Dim x As Long

LongTimer = Timer
VariantTimer = Timer
SingleTimer = Timer
DoubleTimer = Timer

MsgBox "Long " & LongTimer & vbNewLine _
& "Sng " & SingleTimer & "
& "
Var " & VariantTimer & "
& "Doub " & DoubleTimer & "
Title:="
  Timer Things                                              "

Do Until x = 100
'waste some time
x = x + 1
Loop

LongTimer = Timer - LongTimer
SingleTimer = Timer - SingleTimer
VariantTimer = Timer - VariantTimer
DoubleTimer = CDbl(Timer) - DoubleTimer

MsgBox "Long " & LongTimer & vbNewLine _
& "
Sng " & SingleTimer & vbNewLine _
& "
Var " & VariantTimer & vbNewLine _
& "
Doub " & DoubleTimer & vbNewLine, _
Title:="
  Timer Things"

End Sub

Run this a few times - some times the reults are "perfect" subtractions". I dont really understand what's going on here, i dont think the double stores at a higher "resolution". Also the cdbl(timer) is a bit unfair....
Any ideas/thoughts