Nov 27, 2007

memo of VB.Net 2005 I

Purpose
  (I can't remember very exactly)

Return an interger of weekday,while 1 to 7 stands for "Sun" to "Sat":
DatePart("w", year & "/" & month & "/" & day)

Add spaces:
Space(number)
  in case of lower ver.:
     Function Sps(ByVal n As Integer) As String
        Return String.Empty.PadLeft(n)
     End Function


Return multi value in function:
outside the function: Dim days(2) as ..
the end of function:  days(0)=..
                              days(1)=..
                              Return days

memo of MS.Excel.VBA I

Purpose
 The purposes are written in blue words. 

Add sheet after the exists:
w = ActiveWorkbook.Worksheets.Count
'NOT "ThisWorkbook", USE "ActiveWorkBook" if it will be made as an Addin
Worksheets.Add After:=Worksheets(w)
Worksheets(w + 1).Name = "temp sheet"


Sort whole sheet according to one column:
Range(Cells(1, 1), Cells(iRow, iCol)).Sort Key1:=Range("C1"), Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod:=xlPinYin, DataOption1:=xlSortNormal
'Range() to select whole sheet while Key1:=Range() to select the column


Check whether the Cell is empty, not null:
ActiveSheet.Cells(iRow, iCol) = Empty

Check whether cell's=listbox's content in a loop:
ActiveSheet.Cells(iRow, iCol) = Form.ListBox.List(k)