Click here to Skip to main content
15,915,019 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Can not get security code from an Keyboard Wedge Ibutton reader ( ps/2 ) Pin
Dave Kreskowiak30-Sep-09 14:42
mveDave Kreskowiak30-Sep-09 14:42 
GeneralRe: Can not get security code from an Keyboard Wedge Ibutton reader ( ps/2 ) Pin
andre de jong1-Oct-09 0:32
andre de jong1-Oct-09 0:32 
GeneralRe: Can not get security code from an Keyboard Wedge Ibutton reader ( ps/2 ) Pin
Dave Kreskowiak1-Oct-09 1:10
mveDave Kreskowiak1-Oct-09 1:10 
GeneralRe: Can not get security code from an Keyboard Wedge Ibutton reader ( ps/2 ) Pin
andre de jong1-Oct-09 1:51
andre de jong1-Oct-09 1:51 
GeneralRe: Can not get security code from an Keyboard Wedge Ibutton reader ( ps/2 ) [modified] Pin
andre de jong1-Oct-09 3:25
andre de jong1-Oct-09 3:25 
AnswerRe: Can not get security code from an Keyboard Wedge Ibutton reader ( ps/2 ) Pin
εїзεїзεїз30-Sep-09 20:26
εїзεїзεїз30-Sep-09 20:26 
GeneralRe: Can not get security code from an Keyboard Wedge Ibutton reader ( ps/2 ) Pin
andre de jong1-Oct-09 0:38
andre de jong1-Oct-09 0:38 
Questioninheritance Pin
rbjanaki30-Sep-09 10:13
rbjanaki30-Sep-09 10:13 
I have to write an inheritance hierarchy for class Quadrilateral,square and rectangle. Use Quadrilateral as base class of the hierarchy.

so for i had this
Public MustInherit Class Quadrilateral
    Public Function getName() As String
        Return "Shape"
    End Function
    Public Function Area() As Double
        Return 0
    End Function
End Class
Public MustInherit Class Twodimensional
    Inherits Quadrilateral

    Private Mx As Integer
    Private y As Integer
    Public Sub New(ByVal xValue As Integer, ByVal yValue As Integer)
        Mx = xValue
        y = yValue
    End Sub
    Public Property xpoint() As Integer
        Get
            Return Mx
        End Get
        Set(ByVal value As Integer)
            Mx = value
        End Set
    End Property
    Public Property Ypoint() As Integer
        Get
            Return y
        End Get
        Set(ByVal value As Integer)
            y = value
        End Set
    End Property
End Class

Public Class Square
    Inherits Twodimensional


    Public sd As Double

    Public Sub New()
        MyBase.New(0, 0)
        Side = 0
    End Sub

    Public Sub New(ByVal xValue As Integer, ByVal yValue As Integer, ByVal side As Double)
        MyBase.New(xValue, yValue)
        sd = side
    End Sub

    Public Property Side() As Double
        Get
            Return sd
        End Get
        Set(ByVal Value As Double)
            If Value <= 0 Then
                sd = 0
            Else
                sd = Value
            End If
        End Set
    End Property
    Public Overloads Function Area() As Double
        Return sd * sd
    End Function

    Public Overloads Function getName() As String

        Return "Square"

    End Function
End Class
Public Class Rectangle
    Inherits Twodimensional


    Public height As Double
    Public wdith As Double

    Public Sub New()
        MyBase.New(0, 0)
        height = 0
        wdith = 0
    End Sub

    Public Sub New(ByVal xValue As Integer, ByVal yValue As Integer, ByVal height As Double, ByVal wdith As Double)
        MyBase.New(xValue, yValue)
        height = height
        wdith = wdith
    End Sub

    Public Property h() As Double
        Get
            Return height
        End Get
        Set(ByVal Value As Double)
            If Value <= 0 Then
                height = 0
            Else
                height = Value
            End If
        End Set
    End Property
    Public Property W() As Double
        Get
            Return wdith
        End Get
        Set(ByVal Value As Double)
            If Value <= 0 Then
                wdith = 0
            Else
                wdith = Value
            End If
        End Set
    End Property
    Public Overloads Function Area() As Double
        Return 2 * (height * wdith)
    End Function

    Public Overloads Function getName() As String

        Return "Rec"

    End Function
End Class



Module Module1
    Sub main()
        Dim i As Integer
        Dim shapes(1) As Quadrilateral

        shapes(0) = New Square(0, 0, 5)
        shapes(1) = New Rectangle(1, 1, 2, 10)
        For i = 0 To shapes.GetUpperBound(0)
            If TypeOf shapes(i) Is Twodimensional Then
                Dim shape As Twodimensional = _
                CType(shapes(i), Twodimensional)
                Console.WriteLine("Two:" & vbCrLf & "Name: " & vbTab & _
                                  "{0}" & vbCrLf & "Values: " & vbTab & _
                                  "{1}" & vbCrLf & "Area: " & vbTab & _
                                  "{2}" & vbCrLf, shape.getName(), shape.Area())
            Else
                Console.WriteLine("No such shape")
            End If

        Next
    End Sub

End Module


I am getting a runtime error like this

Unhandled Exception: System.FormatException: Index (zero based) must be greater
than or equal to zero and less than the size of the argument list.
at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String fo
rmat, Object[] args)
at System.String.Format(IFormatProvider provider, String format, Object[] arg
s)
at System.IO.TextWriter.WriteLine(String format, Object arg0, Object arg1)

Press any key to continue . . .
AnswerRe: inheritance Pin
Dave Kreskowiak30-Sep-09 10:39
mveDave Kreskowiak30-Sep-09 10:39 
GeneralRe: inheritance Pin
rbjanaki30-Sep-09 10:46
rbjanaki30-Sep-09 10:46 
GeneralRe: inheritance Pin
Christian Graus30-Sep-09 11:16
protectorChristian Graus30-Sep-09 11:16 
GeneralRe: inheritance Pin
Dave Kreskowiak30-Sep-09 11:25
mveDave Kreskowiak30-Sep-09 11:25 
GeneralRe: inheritance Pin
Gideon Engelberth30-Sep-09 18:03
Gideon Engelberth30-Sep-09 18:03 
QuestionImage Manipulation Questions Pin
Roland7130-Sep-09 9:42
Roland7130-Sep-09 9:42 
AnswerRe: Image Manipulation Questions Pin
Dave Kreskowiak30-Sep-09 10:31
mveDave Kreskowiak30-Sep-09 10:31 
QuestionXML Export and Import Pin
tjutagir30-Sep-09 6:01
tjutagir30-Sep-09 6:01 
AnswerRe: XML Export and Import Pin
Dave Kreskowiak30-Sep-09 7:23
mveDave Kreskowiak30-Sep-09 7:23 
QuestionAccessing an Authentication Popup box Pin
spamnchips30-Sep-09 4:19
spamnchips30-Sep-09 4:19 
QuestionWindows Service Pin
Archimedes2430-Sep-09 2:41
professionalArchimedes2430-Sep-09 2:41 
AnswerRe: Windows Service Pin
tosch30-Sep-09 3:57
tosch30-Sep-09 3:57 
AnswerRe: Windows Service Pin
Steven J Jowett30-Sep-09 4:45
Steven J Jowett30-Sep-09 4:45 
AnswerRe: Windows Service Pin
darkelv30-Sep-09 5:41
darkelv30-Sep-09 5:41 
QuestionText Box Color Black Pin
Anubhava Dimri29-Sep-09 21:36
Anubhava Dimri29-Sep-09 21:36 
AnswerRe: Text Box Color Black Pin
Christian Graus29-Sep-09 22:13
protectorChristian Graus29-Sep-09 22:13 
QuestionVB.Net - How do I get string before the @ chr in an email address Pin
Member 442053429-Sep-09 20:25
Member 442053429-Sep-09 20:25 

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.