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
'This is a VB version of the C# code by Mike Bevers as of 19 Aug 2015 12:07 at | |
'http://www.mikebevers.be/blog/2010/02/extended-combobox-with-a-selection-changing-event/ | |
'Usage: | |
'Private Sub BetterComboBox1_SelectedIndexChanging( _ | |
' sender As System.Object, _ | |
' e As System.ComponentModel.CancelEventArgs _ | |
') Handles BetterComboBox1.SelectedIndexChanging | |
' | |
' If True Then |
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
' Requires `Imports System.Runtime.CompilerServices` | |
Module Extensions | |
<Extension()> | |
Public Function Fill(Of T)(cb As Control, cc As ICollection(Of T)) As Integer | |
Dim cbc As ComboBox = CType(cb, ComboBox) | |
Dim n As Integer = 0 | |
If cc.Count = 0 Then | |
Return False | |
End If | |
For Each cn In cc |
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
Private Function GetSerialPortNames() As List(Of String) | |
Dim PortNames As New List(Of String) | |
For Each PortName In My.Computer.Ports.SerialPortNames | |
PortNames.Add(PortName) | |
Next | |
Return PortNames | |
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
'Usage: ListBox1.AddLogLine("Log this!") | |
Imports System.Runtime.CompilerServices | |
Module FormExtensions | |
Delegate Sub UpdateLog(lb As ListBox, line As String) | |
<Extension()> | |
Public Sub AddLogLine(lb As ListBox, line As String) | |
If (lb.InvokeRequired) Then 'Invoke from the GUI thread if called from a different one | |
lb.Invoke(New UpdateLog(AddressOf AddLogLine), lb, line) |
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
/* bar.c */ | |
#include foo.h | |
int bar (void) | |
{ | |
int a = 5, b = 0; | |
e = foo(a, &b); /* Note b is local, thus test won't know its address. */ | |
/* ... use b ... */ | |
return e; | |
} |
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
kind classify_number(int n) | |
{ | |
kind class = error; | |
if (n > 0) { | |
int buf = aliquot_sum(n); | |
if (buf > n) { | |
class = abundant_number; | |
} else if (buf < n) { | |
class = deficient_number; | |
} else { |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reflection; | |
namespace FooProgram | |
{ | |
public static class DerivedClassEnumerator | |
{ | |
// Class that list all the types derived from a given type |
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
Option Strict On | |
Option Explicit On | |
Imports System.Runtime.InteropServices | |
Imports System.Runtime.CompilerServices | |
Module ConvertWithSign | |
' These extensions allow conversion from an unsigned type to the equivalent | |
' signed type, and vice versa, while preserving the sign bit. | |
' |
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
using System.Reflection | |
public class Gists | |
{ | |
public Dictionary<string, object> GetDictionaryOfProperties(o As Object) | |
{ | |
Dictionary<string,string> Properties; | |
Properties = (from x in o.GetType().GetProperties() select x).ToDictionary | |
( x => x.Name, x => x.GetGetMethod().Invoke (o, null)); |
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
Option Strict On | |
Option Explicit On | |
Imports System.Reflection | |
Module Gists | |
Public Function GetDictionaryOfProperties(ByRef o As Object) As Dictionary(Of String, Object) | |
Dim Properties As Dictionary(Of String, Object) = New Dictionary(Of String, Object) | |
#If Not USE_LOOP |