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.

VBA:
  1. Sub CombineFormulas()
  2. Dim objCell As Object
  3. Dim sTemp As String
  4. Dim sOperator As String
  5. Dim rOutPut As range
  6.  
  7. On Error GoTo errorhandel
  8.  
  9. sOperator = InputBox("Operator to use?", "CombineFormulas")
  10.  
  11. For Each cell In Selection
  12. If Len(cell.Cells.Formula)> 1 Then
  13. ''get the formula, adds a "(" , remove the "=", add the closing ")", and puts a "+" on the end
  14. sTemp = sTemp & "(" & Right(cell.Cells.Formula, (Len(cell.Cells.Formula) - 1)) & ")" & sOperator
  15. Else
  16. End If
  17. Next
  18.  
  19. ''Puts an "=" at the start, then gets rid of the last "+",
  20. sTemp = "=" & Left(sTemp, Len(sTemp) - 1)
  21.  
  22. Set rOutPut = Application.InputBox("Put In Cell", Type:=8)
  23.  
  24. ActiveSheet.range(rOutPut.Address).Formula = sTemp
  25.  
  26. Exit Sub
  27.  
  28. errorhandel:
  29. MsgBox "Error: " & vbNewLine _
  30. & Err.Description & vbNewLine _
  31. & Err.Number, _
  32. vbOKOnly, "CombineFormulas"
  33. 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?

VBA:
  1. Sub TimerTest()
  2.  
  3. Dim LongTimer  As Long
  4. Dim VariantTimer As Variant
  5. Dim DoubleTimer As Double
  6. Dim IntegerTimer As Integer
  7. Dim SingleTimer As Single
  8. Dim x As Long
  9.  
  10. LongTimer = Timer
  11. VariantTimer = Timer
  12. SingleTimer = Timer
  13. DoubleTimer = Timer
  14.  
  15. MsgBox "Long " & LongTimer & vbNewLine _
  16. & "Sng " & SingleTimer & "
  17. & "Var " & VariantTimer & "
  18. & "Doub " & DoubleTimer & "
  19. Title:="  Timer Things                                              "
  20. Do Until x = 100
  21. 'waste some time
  22. x = x + 1
  23. Loop
  24. LongTimer = Timer - LongTimer
  25. SingleTimer = Timer - SingleTimer
  26. VariantTimer = Timer - VariantTimer
  27. DoubleTimer = CDbl(Timer) - DoubleTimer
  28. MsgBox "Long " & LongTimer & vbNewLine _
  29. & "Sng " & SingleTimer & vbNewLine _
  30. & "Var " & VariantTimer & vbNewLine _
  31. & "Doub " & DoubleTimer & vbNewLine, _
  32. Title:="  Timer Things"
  33. 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