Click here to Skip to main content
14,837,450 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionTrig in vb [modified] Pin
ummoops3-May-07 14:42
Memberummoops3-May-07 14:42 
AnswerRe: Trig in vb Pin
Arun.Immanuel3-May-07 15:58
MemberArun.Immanuel3-May-07 15:58 
GeneralRe: Trig in vb Pin
ummoops3-May-07 16:27
Memberummoops3-May-07 16:27 
Questionexecute in context of different user Pin
TeachesOfPeaches3-May-07 11:35
MemberTeachesOfPeaches3-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
MemberTeachesOfPeaches4-May-07 4:45 
QuestionBubble sort an array of Structure Pin
amatbrewer3-May-07 11:35
Memberamatbrewer3-May-07 11:35 
AnswerRe: Bubble sort an array of Structure Pin
TwoFaced3-May-07 13:35
MemberTwoFaced3-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
Memberfp2billiards3-May-07 11:05 
AnswerRe: Checking for overlapping timespans Pin
Arun.Immanuel3-May-07 15:53
MemberArun.Immanuel3-May-07 15:53 
QuestionUsing a filter on BindingSource with BindingList Pin
Mightor3-May-07 9:44
MemberMightor3-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
MemberMightor4-May-07 9:17 
QuestionConvert 2003 to 2005 Errors Pin
Central_IT3-May-07 9:34
MemberCentral_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
MemberCentral_IT3-May-07 9:49 
GeneralRe: Convert 2003 to 2005 Errors Pin
Central_IT3-May-07 10:02
MemberCentral_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
MemberCentral_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
MemberRichFeldman3-May-07 8:23 
AnswerRe: Creating a Help System for a VB.NET Project Pin
MatrixCoder3-May-07 11:19
MemberMatrixCoder3-May-07 11:19 
Question[02/03] Please help graphing datasource Pin
Srigopal0073-May-07 8:19
MemberSrigopal0073-May-07 8:19 
QuestionError While Creating Publish Pin
vurugonda3-May-07 7:53
Membervurugonda3-May-07 7:53 
QuestionInstalling a Windows Service and the GAC Pin
Terry Porter3-May-07 6:04
MemberTerry 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.