Lambda

Lamda Where


If cPadMain.PadHistoryList.Where(Function(h) h.IsNew = True).Count <> 0 Then
Dim cPadHistoryData As New PadHistoryData(Me.ConnectionStringSettings)
For Each ph As PadHistory In cPadMain.PadHistoryList.Where(Function(h) h.IsNew = True)
cPadHistoryData.Insert(ph)
Next
End If

Lamda Max

Dim dList As IList(Of Decision) = CType(DecisionBindingSource.DataSource, IList(Of Decision))
dNew.ID = dList.Max(Function(d) d.ID) + 1

Lamda check for repeats

Public Function IsSupplierPriorityOK() As Boolean
 
    'Lambda Check for repeats
    For Each cs1 As Costing.ComponentSupplier In Me.ComponentSupplierList.OrderBy(Function(h) h.Priority)
        Dim p1 As Integer = cs1.Priority
        If Me.ComponentSupplierList.Where(Function(h) h.Priority = p1).Count <> 1 Then
            Return False
        End If
    Next
    Return True
 
End Function

ToolStripTextBox as Password

 

Can I make a ToolStripTextBox show a character if I am using it for a password ie a * instead of a character as you can in a textbox ? Yes

ToolStripTextBox1.TextBox.PasswordChar = "*"c

From http://vbcity.com/forums/topic.asp?tid=153131

 

Error handling Stack Frame

Technorati Tags:
 

Dim stackFrame As New Diagnostics.StackFrame(1)
Dim sProcedure As String = stackFrame.GetMethod.Name
Dim sModuleName As String = stackFrame.GetMethod.DeclaringType.FullName

Set ToolStripTextBox Focus when Opening the form

me.ActiveControl=me.ToolStripTextBox.Control
You also need to set the ToolStrip’s (not the ToolStripTextBox’s – it doesn’t have the property) TabStop property to True.
Also if you set this active control on form load, then if you hide the form you may change the focus when it becomes visible again.
Could use following

PrivateSub frm_VisibleChanged(sender AsObject, e As System.EventArgs) HandlesMe.VisibleChanged

If Me.Visible Then
           ‘ToolStrip1.TabStop = True
            ActiveControl = InputProductToolStripTextBox.Control
   End If

EndSub

Lambda Enumerable..::.First<(Of )>) Generic Method (IEnumerable<(Of )>), Func<(Of )>))

 
 
ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/fxref_system.core/html/d232a6bf-5e64-d5b8-83f5-a0cf110f4107.htm
 

Public Function IsServiceRuning(ByVal scName As String) As Boolean

Dim scServices() As ServiceController
scServices = ServiceController.GetServices
Dim sc As ServiceController = scServices.First(Function(s) s.ServiceName = scName)
If sc.Status = ServiceControllerStatus.Running Then
Return True
End If

End Function

GetOleDbSchemaTable Table Column Schema from JET MS Access

Public Sub GetDatabaseTableColumns()
Try
Dim table As DataTable
Using cn As New OleDb.OleDbConnection(My.Settings.conStrOneWay)
cn.Open()
Dim restrictionValues As String() = New String() {Nothing, Nothing, "Quotes", Nothing}
table = cn.GetOleDbSchemaTable(OleDb.OleDbSchemaGuid.Columns, restrictionValues)
cn.Close()
End Using

Call DisplayData(table)

Catch ex As Exception
Throw ex
End Try
End Sub

Private Sub DisplayData(ByVal table As DataTable)
For i = 0 To table.Rows.Count - 1
Dim msg As String = table.Rows(i)!COLUMN_NAME.ToString & vbTab & table.Rows(i)!DATA_TYPE.ToString
Console.WriteLine(msg)
Debug.Print(msg)
Next i
End Sub

 

 

Code Generation using System.CodeDom

 
 
Create a code generation project.
For instance to create a class automatically from a database table. Successfully done this in VB.Net Project "CodeGeneration"
 
Now use to quickly create classes for RAD – Rapid Application Development
 
 
 
Found adding a blank line difficult. Answer is here
 

Dim blankLine As New CodeSnippetTypeMember("")
targetClass.Members.Add(blankLine)
 

When creating the Property Set Statements I have found that the Set does not include the (ByRef value as string) part.
However when using the class for the first time, just press return after the Class name and all of these are inserted automatically.

Steve

 
 

Delegate Test

 

Imports Microsoft.VisualBasic.CallType

Public Class TestJump
Inherits Test

Delegate Sub T()

Public Overrides Sub RunTest()

Try
'Call TestBack()
Dim st As New StackFrame
Me.Name = st.GetMethod.ReflectedType.Name
Dim op As T = AddressOf TestBack
op.Invoke()
Call TestDelegate(AddressOf TestMe.TestBack)
Me.Result = True

Catch ex As Exception
Me.Result = False
Me.FailMessage = ex.Message
End Try

End Sub

Private Sub TestDelegate(ByVal op As T)
op.Invoke()
End Sub

End Class

Module TestMe
Public Sub TestBack()
Debug.Print("Here123")
'Debug.Close()
End Sub
End Module

Talking about NULLABLE datagridviewcomboboxcolumn (vbnet 2005)

 
 
Unresolved
Untried
How to allow used to remove an entry from a DataGridViewComboBoxColumn
 
Possibly try
 
 

Report Data Sources

 
When designing a report there is an extra top menu. So use Report > Data Sources.
Ideally DataSource is in same project. Possibly use Objects in future if not in same project. Seems awkward.
 
Error "The source of the report definition has not been specified"
 
Dim ds As New dsA
Dim ta As New dsATableAdapters.ATableAdapter
ta.Fill(ds.A)
Dim bs As New Windows.Forms.BindingSource(ds, ds.A.TableName)
 
Dim ReportDataSource1 As ReportDataSource = New ReportDataSource
ReportDataSource1.Name = "dsA_A"    'Important to use datasource name as used on report
ReportDataSource1.Value = bs
 
With Me.ReportViewer1.LocalReport
    .DataSources.Add(ReportDataSource1)
    .DataSources(0).Value = bs
End With