Category Archives: Coding Snipbits

Excel VBA reminders / snipbits

Consider using Collections, not arrays Use SET when assigning Objects Set InvoiceWS = ActiveWorkbook.Sheets(“Invoice”) Function InArray(arr, val) As Boolean    For arrloop = LBound(arr) To UBound(arr)       If arr(arrloop) = val Then         InArray = True         Exit Function       End If    Next arrloop    InArray = False End Function Dim ListOfDirectors As Variant:… Read More »

Delphi Validating UK postcodes

http://www.daniweb.com/software-development/pascal-and-delphi/threads/276733/postcode-validation http://www.ml-consult.co.uk/foxst-39.htm function ValidPostcode(anInput: String): Boolean; var iSpacePos, I: byte; sInward, sOutward: String; begin Result := False; if (anInput = EmptyStr) then Exit; anInput := UpperCase(anInput); iSpacePos := Pos(‘ ‘, anInput); if iSpacePos = 0 then Exit; sInward := Copy(anInput, iSpacePos + 1, 3); sOutward := Copy(anInput, 1, iSpacePos – 1); if StrToIntDef(sInward[1], -1) =… Read More »