fast vb help

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
8 posts Page 1 of 1
Contributors
User avatar
troop
Dedicated Member
Dedicated Member
Posts: 75
Joined: Sat Sep 28, 2013 11:57 am

fast vb help
troop
hey i know this might just be 1 letter but idk what it is or how to do it, i want to do

If textbox1.text = "airplane" or "plane" then
frmPlane.show()
end if

this is just a random example but the or doesn't work, if i put it it would mess up my program, is there any way to do

If textbox1.text = "123" or "321" or "1234" like 3 or more ?

pls tell
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

Re: fast vb help
Shim
Use OrElse
Code: Select all
if textbox1.text = "airplane" OrElse "plane" then
frmPlane.show()
End if
Or Use AndAlso
Code: Select all
if textbox1.text = "airplane" AndAlso "plane" then
frmPlane.show()
End if
Find my programs on Softpedia
User avatar
noypikami
VIP - Donator
VIP - Donator
Posts: 151
Joined: Sat Dec 22, 2012 1:49 am

Re: fast vb help
noypikami
try to do it like this:
declare the string for the specific textbox:

if textbox1.text = "airplane" or textbox1.text="plane" then
frmPlane.show()
end if


or=============
Code: Select all
If textbox1.text = "123" or textbox1.text = "321" or textbox1.text = "1234"  then
form2.show
end if
User avatar
troop
Dedicated Member
Dedicated Member
Posts: 75
Joined: Sat Sep 28, 2013 11:57 am

Re: fast vb help
troop
thanks i will try both loove;
User avatar
visualtech
VIP - Donator
VIP - Donator
Posts: 265
Joined: Sat Nov 19, 2011 2:19 pm

Re: fast vb help
visualtech
Depending what you want to compare, there are quite a few functions (or logics to be precise).

Case #1: Integer and Integer (e.g. 2 and 4)
Code: Select all
Dim a As Integer = 2
Dim b As Integer = 4

If a = b Then
    ' Do something.
End If
Case #2: Integer and Integer but provided as a string.
Code: Select all
Dim aString As String = "2"
Dim bString As String = "4"

Dim a As Integer = Integer.Parse(aString)
Dim b As Integer = Integer.Parse(bString)

If a = b Then
    ' Do Something
End If
Case #3: String and String
Code: Select all
Dim a As String = "helloWorld"
Dim b As String = "howAreYou"

If a.Equals(b) Then
    ' Do Something
End If

' Another approach can be

If a = b Then
    ' Do something
End If
That sums up all I can think of right now. For more, PM me ;)
Image
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Re: fast vb help
XTechVB
Like this
Code: Select all
        If TextBox1.Text = "1" Or TextBox1.Text = "2" Or TextBox1.Text = "3" Then
            frmPlane.show()
        End If
You can find me on Facebook or on Skype mihai_92b
User avatar
troop
Dedicated Member
Dedicated Member
Posts: 75
Joined: Sat Sep 28, 2013 11:57 am

Re: fast vb help
troop
thanks all im sorry visualtech u r very helpful but it was not my question but i like it ty loove; loove; loove;

XTech and other has wht i want thanks loove; :oops:
User avatar
noypikami
VIP - Donator
VIP - Donator
Posts: 151
Joined: Sat Dec 22, 2012 1:49 am

Re: fast vb help
noypikami
Please Lock this thread when it's been answered already. :)
8 posts Page 1 of 1
Return to “Coding Help & Support”