https://docs.google.com/document/d/15VwHVhVgC0rcSmA4Ik1bIH46yIrc-65XE0C_ONFejWE/edit
Tuesday, March 27, 2012
Tuesday, August 9, 2011
System.Collections.Generic Namespace ()
"System.Collections.Generic Namespace ()" ( http://bit.ly/qqtEH3 )
Using Classes and Structures in Visual Basic .NET
"Using Classes and Structures in Visual Basic .NET" ( http://bit.ly/n4jVjJ )
Labels:
Class,
Link,
MSDN,
Reference Types,
Storage,
Structures,
Value Types
Value Types and Reference Types
"Value Types and Reference Types" ( http://bit.ly/r2mnZE )
Tuesday, May 10, 2011
EXCEL VBA TOC
Sub CreateTOC()
' Code by Zack Baresse
If ActiveWorkbook Is Nothing Then
MsgBox "You must have a workbook open first!", vbInformation, "No Open Book"
Exit Sub
End If
With Application
.ScreenUpdating = False
.DisplayAlerts = False
Dim ws As Worksheet, _
ct As Chart, _
shtName As String, _
nrow As Long, _
tmpCount As Long, _
i As Long, _
numCharts As Long
nrow = 3
i = 1
numCharts = ActiveWorkbook.Charts.Count
On Error GoTo hasSheet
Sheets("Table of Contents").Activate
If MsgBox("You already have a Table of Contents page. Would you like to overwrite it?", _
vbYesNo + vbQuestion, "Replace TOC page?") = vbYes Then GoTo createNew
Exit Sub
hasSheet:
Sheets.Add Before:=Sheets(1)
GoTo hasNew
createNew:
Sheets("Table of Contents").Delete
GoTo hasSheet
hasNew:
tmpCount = ActiveWorkbook.Charts.Count
If tmpCount > 0 Then tmpCount = 1
ActiveSheet.Name = "Table of Contents"
With Sheets("Table of Contents")
'.Cells.Interior.ColorIndex = 4
With .Range("B2")
.Value = "Table of Contents"
.Font.Bold = True
.Font.Name = "Calibri"
.Font.Size = "24"
End With
End With
For Each ws In ActiveWorkbook.Worksheets
nrow = nrow + 1
With ws
shtName = ws.Name
With Sheets("Table of Contents")
.Range("B" & nrow).Value = nrow - 3
.Range("C" & nrow).Hyperlinks.Add _
Anchor:=Sheets("Table of Contents").Range("C" & nrow), Address:="#'" & _
shtName & "'!A1", TextToDisplay:=shtName
.Range("C" & nrow).HorizontalAlignment = xlLeft
End With
End With
Next ws
If numCharts <> 0 Then
For Each ct In ActiveWorkbook.Charts
nrow = nrow + 1
shtName = ct.Name
With Sheets("Table of Contents")
.Range("B" & nrow).Value = nrow - 3
.Range("C" & nrow).Value = shtName
.Range("C" & nrow).HorizontalAlignment = xlLeft
End With
Next ct
End If
With Sheets("Table of Contents")
With .Range("B2:G2")
.MergeCells = True
.HorizontalAlignment = xlLeft
End With
With .Range("C:C")
.EntireColumn.AutoFit
.Activate
End With
.Range("B4").Select
End With
.DisplayAlerts = True
.ScreenUpdating = True
End With
MsgBox "Done!" & vbNewLine & vbNewLine & "Please note: " & _
"Charts are listed after regular " & vbCrLf & _
"worksheets and will not have hyperlinks.", vbInformation, "Complete!"
End Sub
' Code by Zack Baresse
If ActiveWorkbook Is Nothing Then
MsgBox "You must have a workbook open first!", vbInformation, "No Open Book"
Exit Sub
End If
With Application
.ScreenUpdating = False
.DisplayAlerts = False
Dim ws As Worksheet, _
ct As Chart, _
shtName As String, _
nrow As Long, _
tmpCount As Long, _
i As Long, _
numCharts As Long
nrow = 3
i = 1
numCharts = ActiveWorkbook.Charts.Count
On Error GoTo hasSheet
Sheets("Table of Contents").Activate
If MsgBox("You already have a Table of Contents page. Would you like to overwrite it?", _
vbYesNo + vbQuestion, "Replace TOC page?") = vbYes Then GoTo createNew
Exit Sub
hasSheet:
Sheets.Add Before:=Sheets(1)
GoTo hasNew
createNew:
Sheets("Table of Contents").Delete
GoTo hasSheet
hasNew:
tmpCount = ActiveWorkbook.Charts.Count
If tmpCount > 0 Then tmpCount = 1
ActiveSheet.Name = "Table of Contents"
With Sheets("Table of Contents")
'.Cells.Interior.ColorIndex = 4
With .Range("B2")
.Value = "Table of Contents"
.Font.Bold = True
.Font.Name = "Calibri"
.Font.Size = "24"
End With
End With
For Each ws In ActiveWorkbook.Worksheets
nrow = nrow + 1
With ws
shtName = ws.Name
With Sheets("Table of Contents")
.Range("B" & nrow).Value = nrow - 3
.Range("C" & nrow).Hyperlinks.Add _
Anchor:=Sheets("Table of Contents").Range("C" & nrow), Address:="#'" & _
shtName & "'!A1", TextToDisplay:=shtName
.Range("C" & nrow).HorizontalAlignment = xlLeft
End With
End With
Next ws
If numCharts <> 0 Then
For Each ct In ActiveWorkbook.Charts
nrow = nrow + 1
shtName = ct.Name
With Sheets("Table of Contents")
.Range("B" & nrow).Value = nrow - 3
.Range("C" & nrow).Value = shtName
.Range("C" & nrow).HorizontalAlignment = xlLeft
End With
Next ct
End If
With Sheets("Table of Contents")
With .Range("B2:G2")
.MergeCells = True
.HorizontalAlignment = xlLeft
End With
With .Range("C:C")
.EntireColumn.AutoFit
.Activate
End With
.Range("B4").Select
End With
.DisplayAlerts = True
.ScreenUpdating = True
End With
MsgBox "Done!" & vbNewLine & vbNewLine & "Please note: " & _
"Charts are listed after regular " & vbCrLf & _
"worksheets and will not have hyperlinks.", vbInformation, "Complete!"
End Sub
Tuesday, April 26, 2011
Gridview DataBound Event
This event fires once the Gridview has finished Databinding - that is, the Gridview has been populated with all of the data on the Datasource.
Don't get it mixed up with RowDataBound event which fires after each row has finished binding.
This is a great place to run any code that needs to wait until the Gridview is finished binding - perhaps we have been accumulating the values in each row, as they bind & wish to write them out at the end.
"BaseDataBoundControl.DataBound Event (System.Web.UI.WebControls)" ( http://bit.ly/gXWo3S )
Don't get it mixed up with RowDataBound event which fires after each row has finished binding.
This is a great place to run any code that needs to wait until the Gridview is finished binding - perhaps we have been accumulating the values in each row, as they bind & wish to write them out at the end.
"BaseDataBoundControl.DataBound Event (System.Web.UI.WebControls)" ( http://bit.ly/gXWo3S )
Labels:
ASP.NET,
databinding,
Databound,
DataSource,
Gridview,
Link,
MSDN
Finding controls in the GridView
Because a GridView renders out multiple rows, each of them contain controls with identical names. Finding the right control requires a trick.
For instance, in the RowDataBound/DataBound event, if we were looking for a particular label so that we could write a value to it 'on the fly', we would use the following code:
The CTYPE function is a conversion function. In this case, it will return all of the data associated with the label we are trying to locate, as a Label object. Once located, we can manipulate this particular instance.
For instance, in the RowDataBound/DataBound event, if we were looking for a particular label so that we could write a value to it 'on the fly', we would use the following code:
Dim lblItemotal As Label = CType(e.Row.FindControl("lblItemTotal"), Label)
The CTYPE function is a conversion function. In this case, it will return all of the data associated with the label we are trying to locate, as a Label object. Once located, we can manipulate this particular instance.
Labels:
ASP.NET,
Conversion,
CTYPE,
Databound,
e,
FindControl,
Gridview,
Link,
MSDN,
row
Subscribe to:
Posts (Atom)