Wednesday, 7 December 2011

SVG innerHTML

In SVG, you don't always use the innerHTML command to write to a tag.  Use the node.textContent
command instead

Wednesday, 23 November 2011



if AscW(UpperCase({vuln_exams.Grade})) = AscW({vuln_exams.Grade}) then
    20
else
    10

In crystal reports, this gives the ability to see whether a character is upper case of not. The equivalent of isUpper()

Wednesday, 28 September 2011

VB cascade row values


Dim c As Integer
c = 9

For r = 7 To 30
    If Cells(r, c) = "" And Cells(r, c - 1) <> "" Then
        Cells(r, c) = Cells(r - 1, c)
    End If
Next r

Sunday, 18 September 2011

converting aac to mp3

cd /home/user/Downloads/iplayer
get_iplayer --get 10457 10458 10459 10460 10461 --force
for i in *.aac; do
    ffmpeg -i "$i" -ac 2 -ab 128 "${i%aac}mp3";
    mv "$i" "aac/";
    mv "${i%aac}mp3" "mp3/";
done

Thursday, 15 September 2011

Excel's dodgy csv output


For some reason excel doesn't export csv's too well.  The major issue being it doesn't force speech marks into the export document and seems to change the dates from YYYY-MM-DD to MM-DD-YYYY.  This isn't letting us submit an ULN report to the Learning Record Service.  The following code creates a CSV with speech marks AND a YYYY-MM-DD date from the area that you select

Sub csvExport()
    Dim fs As Object, a As Object, i As Integer, s As String, t As String, l As String, mn As String
    Set fs = CreateObject("Scripting.FileSystemObject")
   
    Dim filename As String
    filename = "LRB_" & Range("C2").Value & "_" & Format(Date, "DDMMYYYY") & "1230.CSV"

    filename = InputBox(Prompt:="Enter the file name to save to", _
          Title:="CSV file name", Default:=filename)
    Set a = fs.CreateTextFile(filename, True)
   
    For r = 1 To Selection.Rows.Count
        s = """"
        c = 1
        For c = 1 To Selection.Columns.Count
                Dim temp As String
                temp = Selection.Cells(r, c)
                'special character catcher specific to LRS
                temp = Replace(temp, "&", "and")
                temp = Replace(temp, "'", "")
                temp = Replace(temp, ":", "")
             
                If IsDate(temp) And x Like "####-##-##" Then
                    s = s & Format(temp, "YYYY-MM-DD")
                Else
                    s = s & temp
                End If
               
                If c = Selection.Columns.Count Then
                    s = s & """" 'end of row
                Else
                    s = s & """,""" 'mid row
                End If
        Next c
        a.writeline s 'write line
    Next r
    MsgBox ("complete, see your root folder")

End Sub