Visual Basic Tutorial – 47 – Coercion

[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –


Posted

in

by

Tags:

Comments

8 responses to “Visual Basic Tutorial – 47 – Coercion”

  1. Chris Andujar Avatar

    Using textbox!

    Public Class Coercion

    Private Sub btnCoercion_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCoercion.Click

    Dim num1 As Integer = Nothing
    Dim num2 As Double = Nothing

    num1 = TextBox1.Text
    num2 = TextBox1.Text

    If num1 = TextBox1.Text Then
    showDataType(num1)
    ElseIf num2 = TextBox1.Text Then
    showDataType(num2)
    End If
    End Sub

    Private Sub showDataType(ByVal num As Integer)
    MessageBox.Show("This is an Integer", "Data Type", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

    Private Sub showDataType(ByVal num As Double)
    MessageBox.Show("This is a Double", "Data Type", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub
    End Class

  2. MrJcyank Avatar

    This is overloading

  3. Abhinav I Avatar

    coercion is function overloading!!

  4. Ben Berman Avatar

    It'd be nice to see how we're supposed to actually use these, and use one over the other

  5. sudacaenny Avatar

    so when is the good stuff coming?
    I have been waiting for a real aplication, a program that i can go to Start. Open. X program
    I now that all this will go into the program and that these are the basics, but it would be encouraging if we were shown and actual program application
    This is like studying math for so many years without knowing what the heck is that useful for.

  6. Luke Shelley Avatar

    The correct term is coercion. The non-technical name is overloading.

  7. Alex Avatar

    Private Sub showDataType(ByVal num As Boolean)
    MessageBox.Show("This is a boolean")
    End Sub

  8. Michael Gardiner Avatar

    I would have called this overloading?

Leave a Reply

Your email address will not be published. Required fields are marked *