How Do I make it so if u click NO on the msgBox it will close.. here is my code im using..
[php]If TextBox1.Text = "hello" Then
MsgBox("Welcome_- Your PassWord Is -" + TextBox1.Text, MsgBoxStyle.YesNo)
If MsgBoxStyle.YesNo = "No" Then
Me.Close()
End If
Contents.Show()
Me.Hide()[/php]
Anyone Help
[php]Dim MsgResult as string
If TextBox1.Text = "hello" Then
MsgResult = MsgBox("Welcome_- Your PassWord Is -" + TextBox1.Text, MsgBoxStyle.YesNo)
If MsgResult = vbNo Then
Me.Close()
ElseIf MsgResult = vbYes Then
'You answered yes
End If
Contents.Show()
Me.Hide()[/php]
I'm not 100% sure about vbNo in VB.net but it would work like that in VB6
@Mintslice, I wrote a whole tutorial on msgbox's and how to use them, goto tutorial section .
Originally Posted by MintSlice
How Do I make it so if u click NO on the msgBox it will close.. here is my code im using..
[php]If TextBox1.Text = "hello" Then
MsgBox("Welcome_- Your PassWord Is -" + TextBox1.Text, MsgBoxStyle.YesNo)
If MsgBoxStyle.YesNo = "No" Then
Me.Close()
End If
Contents.Show()
Me.Hide()[/php]
Anyone Help
Code:
If Textbox1.text="Hello" Then
If MsgBox("Welcome_- Your PassWord Is -" + TextBox1.Text, MsgBoxStyle.YesNo)=MsgBoxResult.No Then
Me.Close()
End If
Contents.Show()
Me.Hide()
End If
I would use:
[php]If textbox1.text = "hello" then
dim x as msgboxresultat = Msgbox("Welcome_- Your PassWord Is -" + textBox1.Text,MsgBoxStyle.YesNo)
If x = MsgBoxResult.No Then
Me.Close()
What good is just getting the code for vbyesno without understanding it or any other feature, (IMO)
whats IMO and thanks for all your ideas
edit : MJlover still dont work
Originally Posted by MintSlice
whats IMO and thanks for all your ideas
edit : MJlover still dont work
IMO = In My Opinion
IMHO = In My Humble Opinion
Solution
Note: I also made a few changes to your wording and how it was set up, I removed the underscores (_) and replaced them with proper spacing, You can use the & symbol to link words, phrases, and strings.
Example: Using Quick Basic to demonstrate how it works ...
Code:
Print "Hello"
Insert "What is your name"; Name$
Print "Hello" & " " & Name$
If you use the & Symbol, your result would be
Hello "Chosen Name"
[php]
Dim CloseMe As String
CloseMe = MsgBox("Welcome" & " " & "Your PassWord Is" & " " + TextBox1.Text, MsgBoxStyle.YesNo, Microsoft.VisualBasic.MsgBoxStyle.Exclamation + Microsoft.VisualBasic.MsgBoxStyle.YesNo + Microsoft.VisualBasic.MsgBoxStyle.MsgBoxHelp)
If TextBox1.Text = "hello" Then
If CloseMe = vbYes Then
' Contents.Show()
Else
Me.Close()
Me.Dispose()
End If
End If
End Sub
[/php]
The real problem with everyone elses examples is one of two things
the Code Rule (which I will Explain)
Or VbYesNo cannot be converted to type double
Code Rule, Code Reads from top to bottom, always, unless your code has specific calls to make them bounce, but if you are in a sub, expect the actions to be taken unless you specify otherwise.
Example :
[php]
If TextBox1.Text = "hello" Then
MsgBox("Welcome_- Your PassWord Is -" + TextBox1.Text, MsgBoxStyle.YesNo)
If MsgBoxStyle.YesNo = "No" Then
Me.Close()
End If
Contents.Show()
Me.Hide()
[/php]
after the End If your code says Contents.show and Me.Hide, what is to stop that code from running no matter what? , Closing the application?
...Nope..., The code will complete the sub.
Same for Hejsans example, so whenever you want a action to discontinue
use GOTO or Exit Sub
Next Issue in your example is that "Yes" is a string. That's a no go.
And finally @ MJ
MJ says
[php]
If Textbox1.text="Hello" Then
If MsgBox("Welcome_- Your PassWord Is -" + TextBox1.Text, MsgBoxStyle.YesNo)=MsgBoxResult.No Then
Me.Close()
End If
Contents.Show()
Me.Hide()
End If
[/php]
He was half way there, the problem with that is he is not creating a new instance of the message box,
So for Mj's example to work , it should be
[php]
Dim MJClose as String
MjClose = MsgBox("Welcome_- Your PassWord Is -" + TextBox1.Text, MsgBoxStyle.YesNo)
If Textbox1.text="Hello" Then
If mjclose = vbno then
Me.Close()
End If
End If
Contents.Show()
Me.Hide()
[/php]
but to make it work even better use the Else Statement.
[php]
Dim MJClose as String
MjClose = MsgBox("Welcome_- Your PassWord Is -" + TextBox1.Text, MsgBoxStyle.YesNo)
If Textbox1.text="Hello" Then
If mjclose = vbno then
Me.Close()
else
Contents.Show()
Me.Hide()
End If
End If
[/php]
In my example, we create a new instance of the message box
[php]
Dim CloseMe as String' , Here I make my declaration and say set it's data type to string.
[/php]