Click here to Skip to main content
15,924,193 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionTrig in vb [modified] Pin
ummoops3-May-07 14:42
ummoops3-May-07 14:42 
AnswerRe: Trig in vb Pin
Arun.Immanuel3-May-07 15:58
Arun.Immanuel3-May-07 15:58 
GeneralRe: Trig in vb Pin
ummoops3-May-07 16:27
ummoops3-May-07 16:27 
Questionexecute in context of different user Pin
TeachesOfPeaches3-May-07 11:35
TeachesOfPeaches3-May-07 11:35 
AnswerRe: execute in context of different user Pin
Dave Kreskowiak4-May-07 3:45
mveDave Kreskowiak4-May-07 3:45 
GeneralRe: execute in context of different user Pin
TeachesOfPeaches4-May-07 4:45
TeachesOfPeaches4-May-07 4:45 
QuestionBubble sort an array of Structure Pin
amatbrewer3-May-07 11:35
amatbrewer3-May-07 11:35 
AnswerRe: Bubble sort an array of Structure Pin
TwoFaced3-May-07 13:35
TwoFaced3-May-07 13:35 
You can use the sort method found in the Array class. You can implement IComparable in your structure. Basically this allows objects of type MyStructure to be compared. Here is a simple example.
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim people As Person() = {New Person("Bob", "Smith"), New Person("Chris", "Adams")}
        Array.Sort(people)
        For Each p As Person In people
            Console.WriteLine(p.FirstName & ":" & p.LastName)
        Next
    End Sub
End Class

Public Structure Person
    Implements IComparable(Of Person)

    Public FirstName As String
    Public LastName As String

    Public Sub New(ByVal first As String, ByVal last As String)
        FirstName = first
        LastName = last
    End Sub

    Public Function CompareTo(ByVal other As Person) As Integer Implements System.IComparable(Of Person).CompareTo
        Return String.Compare(Me.LastName, other.LastName)
    End Function
End Structure
This will sort alphabetically by the LastName field. If you want to sort in descending order you could first call sort to put them in ascending order and then call array.reverse(YourArray) to put them in descedning order. There are other ways to allow for multiple different sorts. If you want to learn more about it try looking up the interfaces Icomparer, and Icomparable.
QuestionChecking for overlapping timespans Pin
fp2billiards3-May-07 11:05
fp2billiards3-May-07 11:05 
AnswerRe: Checking for overlapping timespans Pin
Arun.Immanuel3-May-07 15:53
Arun.Immanuel3-May-07 15:53 
QuestionUsing a filter on BindingSource with BindingList Pin
Mightor3-May-07 9:44
Mightor3-May-07 9:44 
AnswerRe: Using a filter on BindingSource with BindingList Pin
Dave Kreskowiak4-May-07 3:50
mveDave Kreskowiak4-May-07 3:50 
GeneralRe: Using a filter on BindingSource with BindingList Pin
Mightor4-May-07 9:17
Mightor4-May-07 9:17 
QuestionConvert 2003 to 2005 Errors Pin
Central_IT3-May-07 9:34
Central_IT3-May-07 9:34 
AnswerRe: Convert 2003 to 2005 Errors Pin
Dave Kreskowiak3-May-07 9:42
mveDave Kreskowiak3-May-07 9:42 
GeneralRe: Convert 2003 to 2005 Errors Pin
Central_IT3-May-07 9:49
Central_IT3-May-07 9:49 
GeneralRe: Convert 2003 to 2005 Errors Pin
Central_IT3-May-07 10:02
Central_IT3-May-07 10:02 
GeneralRe: Convert 2003 to 2005 Errors Pin
Dave Kreskowiak3-May-07 13:34
mveDave Kreskowiak3-May-07 13:34 
GeneralRe: Convert 2003 to 2005 Errors Pin
Central_IT4-May-07 1:36
Central_IT4-May-07 1:36 
GeneralRe: Convert 2003 to 2005 Errors Pin
Dave Kreskowiak4-May-07 2:31
mveDave Kreskowiak4-May-07 2:31 
QuestionCreating a Help System for a VB.NET Project Pin
RichFeldman3-May-07 8:23
RichFeldman3-May-07 8:23 
AnswerRe: Creating a Help System for a VB.NET Project Pin
MatrixCoder3-May-07 11:19
MatrixCoder3-May-07 11:19 
Question[02/03] Please help graphing datasource Pin
Srigopal0073-May-07 8:19
Srigopal0073-May-07 8:19 
QuestionError While Creating Publish Pin
vurugonda3-May-07 7:53
vurugonda3-May-07 7:53 
QuestionInstalling a Windows Service and the GAC Pin
Terry Porter3-May-07 6:04
Terry Porter3-May-07 6:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.