Example : How to Print/Display/Output Messages in different format in VB .Net 2013.
Dim Yr As Integer = 15
Dim Mth As Integer = 3
Dim Dt As Integer = 27
MessageBox.Show("Hello You are " + Yr.ToString + " Years " + Mth.ToString + " 
    Months " + Dt.ToString + " Days")
----------------------  OR  -----------------------
 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        MessageBox.Show("Welcome U in Codershelpline")

        MsgBox("Welcome U in Codershelpline")
 End Sub
----------------------  OR  -----------------------
MessageBox.Show(Me, "Incomplete information", "Login Error")
MessageBox.Show("Incomplete information", "Login Error")

'Incomplete information=Message text.
'Login Error=Title of message box.
----------------------  OR  -----------------------
 Label1.Text = "Pls Enter user id and password."
----------------------  OR  -----------------------
       If TextBox1.Text = "" Then
            'MsgBox("Please Enter Customer Id", MsgBoxStyle.Critical, "Save Error")
            'MessageBox.Show("Codershelpline","Important Message")
            'MessageBox.Show("Codershelpline", _
                         "Important Message")
            'MsgBox("Please Enter Customer Id", MsgBoxStyle.Exclamation, "Save Error")
            'MsgBox("Please Enter Customer Id", MsgBoxStyle.Information, "Save Error")
            'MsgBox("Please Enter Customer Id", MsgBoxStyle.Question, "Save Error")
            'MsgBox("Please Enter Customer Id", MsgBoxStyle.OkCancel, "Save Error")
            'MsgBox("Please Enter Customer Id", MsgBoxStyle.YesNo, "Save Error")
            'MsgBox("Please Enter Customer Id", MsgBoxStyle.YesNoCancel, "Save Error")
            MsgBox("Please Enter Customer Id", MsgBoxStyle.AbortRetryIgnore, "Save Error")
            TextBox1.Focus()
            Exit Sub
       End If

'NB: Here "Save Error" is the message appeared as title of message box.we can change it.
----------------------  OR  -----------------------
        Dim k as Integer = MsgBox("DO YOU WANT TO EDIT AGAIN", MsgBoxStyle.YesNo)
        Dim k as Integer = MsgBox("Do You Want To Close The Application [Y/N]?",  
                                   MsgBoxStyle.YesNo,"Close the Application")
        If k = 6 Then
           DataGridView1.Visible = False     
        End If

'NB:Here 6 is the ASCII value for choosing Yes option from appeared message box.
----------------------  OR  -----------------------
'Code to Put Data as Message in a Text Box
  TxtMsgBox.Text=Val(TxtQty1.Text) & " Consumed And " & Val(TxtQty2.Text) & " Wastage."
----------------------  OR  -----------------------
'Code to display data as 11-08-2019 or 11-Aug-2019 format 
   Dim dateAsString As String = DateTime.Now.ToString("dd/MM/yyyy")
   Dim dateAsString As String = DateTime.Now.ToString("dd/MMM/yyyy")
   MsgBox(dateAsString)
----------------------  OR  -----------------------
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim x As String
        x = "Welcome, India is Great"
        MsgBox(" The message is : " & x)
        'MsgBox(" The message is : " + x)
End Sub
----------------------  OR  -----------------------
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim x, y As String
        x = "Welcome, India is Great"
        y = "The world is our family"
        MsgBox(" The message is : = " + x + " and " + y)
        MsgBox(" The message is : = " & x & " and " & y)
End Sub

Loading

Categories: VB .Net Codes

0 Comments

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.