Link to home
Start Free TrialLog in
Avatar of ToddHawley4984
ToddHawley4984

asked on

Multiple subs in class

I have been working through some examples in wrox visual basic 2008 book.  In developing classes there are some instances where the same sub name is used twice.  The author doesn't bother to explain why that is possible or how the calling sub knows which one to use...Can someone explain how you can use the same name for two different subs?  I've included one of the examples.  In this one there are two definitions for "Public Sub Save()...
Imports System.IO
Imports System.Xml.Serialization
 
Public Class SerializableData
    Public Sub Save(ByVal filename As String)
        'make a temporary filename....
        Dim tempFilename As String
        tempFilename = filename & ".tmp"
 
        'does the file exist
        Dim tempFileInfo As New FileInfo(tempFilename)
        If tempFileInfo.Exists = True Then tempFileInfo.Delete()
 
        'open the file
        Dim stream As New FileStream(tempFilename, FileMode.Create)
 
        'save the object
        Save(stream)
        'close the file
        stream.Close()
        'remove the existing data file and 
        'rname the temp file......
 
        tempFileInfo.CopyTo(filename, True)
        tempFileInfo.Delete()
 
    End Sub
 
    'Save  - actually perform the serialization....
    Public Sub save(ByVal stream As Stream)
 
        'create serializer
        Dim serializer As New XmlSerializer(Me.GetType)
 
        'save the file
        serializer.Serialize(stream, Me)
    End Sub
End Class

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Daniel Wilson
Daniel Wilson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ToddHawley4984
ToddHawley4984

ASKER

I see thanks!