Results 1 to 2 of 2

Thread: msgbox code in one line

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2014
    Posts
    3

    msgbox code in one line

    For a long time now, I think, I'm thinking and trying in different ways to push this code in one line. Is there such a possibility at all?

    Code:
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            If MsgBox("Cancel aplications", MsgBoxStyle.YesNo Or MsgBoxStyle.Information, "Cancel aplications") = Windows.Forms.DialogResult.Yes Then
                Me.Close()
            End If
        End Sub
    The code I need to put in such a structure for example:

    If Choosetext.ComboBox1.SelectedItem = "text1" Then

    Form1.Button2.Text = "Text"
    Form1.Button1.MsgBox?

    End If

    Does anyone have a solution like this code put into one line? And is there such an opportunity at all?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: msgbox code in one line

    Firstly, I don't really see what the connection is between the first code snippet and the second, unformatted one. Secondly, why do you think you need to condense either of them to one line?

    Are you saying that you want to be able to prompt the user to exit the application from multiple places? If so then just put the code somewhere common, e.g. a method in a module, and then call that from anywhere you like. You can call Application.Exit to exit the application, so it doesn't matter that you can't call Me.Close in a module.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width