This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dim t As Task(Of String) = Task.Factory.StartNew(Function() | |
Debug.Write("Sleeping for 5 seconds...") | |
Thread.Sleep(5000) | |
Debug.Write("Ready to talk!") | |
Return "Hello World!" | |
End Function).ContinueWith(Sub(x) | |
MessageBox.Show(x.Result) | |
End Sub) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Class CustomComponentResourceManager | |
Inherits System.ComponentModel.ComponentResourceManager | |
Public Sub New(type As Type, resourceName As String) | |
MyBase.New(type) | |
Me.BaseNameField = resourceName | |
End Sub | |
End Class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System.Runtime.CompilerServices | |
Module ControlExtensions | |
''' <summary> | |
''' Checks if control needs invocation and runs action on the main thread | |
''' </summary> | |
''' <param name="control"></param> | |
''' <param name="action"></param> | |
<Extension()> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System | |
Imports System.Collections.Generic | |
Imports System.ComponentModel | |
Imports System.ComponentModel.DataAnnotations | |
Imports FluentValidation | |
Public Class MyObject | |
Implements IEditableObject | |
Implements INotifyPropertyChanged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System.Linq.Expressions | |
Imports System.Reflection | |
Public Module utils | |
''' <summary> | |
''' Returns property info from specified Linq Expression | |
''' </summary> | |
''' <param name="instance">instance of the object that has the propery</param> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<System.Diagnostics.DebuggerStepThrough()> Public Function VbRound(ByVal Number As Double, ByVal DecimalPlaces As Integer) As Double | |
Dim varDec As Double, intX As Long, varX As Double, varDelta As Double | |
varDelta = 10 ^ (-DecimalPlaces) | |
varX = Number / varDelta | |
'intX = Int(varX) | |
intX = Math.Sign(varX) * Int(Math.Abs(varX)) | |
varDec = CDec(varX) - intX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<System.Diagnostics.DebuggerStepThrough()> Public Function SqlDate(ByVal value As Date) As String | |
Return Format(value.Year, "0000") & "-" & Format(value.Month, "00") & "-" & Format(value.Day, "00") | |
End Function | |
<System.Diagnostics.DebuggerStepThrough()> Public Function SqlDateTime(ByVal value As DateTime) As String | |
Return Format(value.Year, "0000") & "-" & Format(value.Month, "00") & "-" & Format(value.Day, "00") & " " & Format(value.Hour, "00") & ":" & Format(value.Minute, "00") & ":" & Format(value.Second, "00") & "." & value.Millisecond.ToString | |
End Function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System.ComponentModel | |
Public Class Class1 | |
Implements IEditableObject | |
#Region "IEditableObject" | |
Private _isEditing As Boolean | |
Private _isRestoring As Boolean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Add repository item to column you want to update | |
2. Handle EditValueChanged | |
3. Call PostEditor() method on gridview | |
Private Sub repItem_EditValueChanged(sender As Object, e As EventArgs) Handles repItem.EditValueChanged | |
gv.PostEditor() | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dim query = From sr In ListProperty | |
Where sr.TaxRate.HasValue AndAlso sr.TaxRate > 0 | |
Group sr By sr.TaxRate Into gr = Group | |
Select TaxRate, Amount = gr.Sum(Function(sr) (sr.Amount - sr.Discount) * (sr.TaxRate / 100)) | |
Dim taxAmount = query.Sum(Function(x) x.Amount) | |
If isNothing(taxAmount) Then | |
Return 0 | |
Else | |
Return Round(taxAmount, 2) |