|
-
Sep 4th, 2017, 01:55 AM
#1
Thread Starter
New Member
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?
-
Sep 4th, 2017, 02:18 AM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|