954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

IF THEN ELSE Statement

Ho guys i got question need to ask about the if else statement:

Can i write like this

IF CUST= "A" OR CUST = "B" OR CUST = "C" THEN CUST = "A , B ,C "

Then statement i pal is if i key either A , B or C is will print out the data of A , B & C.

It is correct is write this using VB?

gingank
Junior Poster
109 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

I'm not sure what exactly you want to do here. Do you want to call specific data and then only show that data? If that data is not available do you want to show all the data?

Please be more specific, and I'm sure we can help here.

AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 

Yes , no doubt you can do that ,

IF CUST= "A" OR CUST = "B" OR CUST = "C" THEN CUST = "A , B ,C "

It is useful when you need to check same condition or to create an advanced search !
I used this when i created an interacting program test.It started like this :

If Text1.Text = "what is your name" Or Text1.Text = "name please" Or Text1.Text = "who are you" Then
MsgBox "My name is System"
ElseIf Text1.Text = "how old are you" Or Text1.Text = "age please" Then
MsgBox "i am 10 years old !"
ElseIf Text1.Text = "please help me" Or Text1.Text = "i need help" Or Text1.Text = "look at me" Then
MsgBox "yes , tell me your problem !"
End If
Vineeth K
Posting Whiz in Training
206 posts since Sep 2009
Reputation Points: 20
Solved Threads: 18
 

I'm not sure what exactly you want to do here. Do you want to call specific data and then only show that data? If that data is not available do you want to show all the data?

Please be more specific, and I'm sure we can help here.


I obly want to call the specific data only that is A,B & C. If i input either one a ,or b it will call out thre data of all the ABC one

gingank
Junior Poster
109 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

yes that will work the way you want.

ProfessorPC
Posting Whiz in Training
270 posts since Dec 2007
Reputation Points: 31
Solved Threads: 29
 

Not that code , this one also work and this is used for more advanced search or security control.In this case the program will work only after comparing 2 conditions at the same time !

If Text1.Text = "what is your name" And Text2.Text = "name please" Then
MsgBox "My name is System"
ElseIf Text1.Text = "how old are you" And Text2.Text = "age please" Then
MsgBox "i am 10 years old !"
ElseIf Text1.Text = "please help me" And Text2.Text = "i need help" Then
MsgBox "yes , tell me your problem !"
End If
Vineeth K
Posting Whiz in Training
206 posts since Sep 2009
Reputation Points: 20
Solved Threads: 18
 

from the question. i take they want it to work if any of the conditions = a b or c. if thats the way it works then yes the first if statement will work

ProfessorPC
Posting Whiz in Training
270 posts since Dec 2007
Reputation Points: 31
Solved Threads: 29
 

simple code

if a=a or b=b or c=c and d=d then f=f
'or 
if a=a or b=b or c=c and d=d then
   f=f
end if

or more

if a=a or b=b or c=c and d=d then
   f=f
else
   f=g
end if


or more

if a=a or b=b or c=c and d=d then
   f=f
elseif  c=c and d=d then
  f=h
elseif   d=d then
  f=i
else
   f=g
end if
omoridi
Junior Poster in Training
72 posts since Sep 2009
Reputation Points: 10
Solved Threads: 10
 

I can't find nothing new in that code ???
I am looking for new IF statements ,

If you got rare and new ideas then
" give me that "
Else
" That code must be waste "
End if
[ hehehehehehehe ]

Vineeth K
Posting Whiz in Training
206 posts since Sep 2009
Reputation Points: 20
Solved Threads: 18
 

i donot know what u want exacly but if vb have iif maybe it work for u

a=iif(b=c,d,f)


this syntax like thsi

if b=c then
   a=d
else
  a=f
end if
omoridi
Junior Poster in Training
72 posts since Sep 2009
Reputation Points: 10
Solved Threads: 10
 

maybe you wnat to some this like "case"?

select case a
   case 1
      b="a1"
   case 2
      b="a2"
   case 3
      b="a3"
   case is>3 and is<10
      b="a4-9"
   case else
      b="a>=10"
end select
omoridi
Junior Poster in Training
72 posts since Sep 2009
Reputation Points: 10
Solved Threads: 10
 

Thanks for that but i never used " select case "

Vineeth K
Posting Whiz in Training
206 posts since Sep 2009
Reputation Points: 20
Solved Threads: 18
 

i need your help huhuh i need to download turbo c so that i can relate in our lesson.....help me guys i dont know to download or install turbo c:S

pressure
Newbie Poster
2 posts since Oct 2009
Reputation Points: 10
Solved Threads: 1
 

i need your help huhuh i need to download turbo c so that i can relate in our lesson.....help me guys i dont know to download or install turbo c

pressure
Newbie Poster
2 posts since Oct 2009
Reputation Points: 10
Solved Threads: 1
 

turbo C on dos?

omoridi
Junior Poster in Training
72 posts since Sep 2009
Reputation Points: 10
Solved Threads: 10
 

please give me at least 10 problems with solution for a if then else statement....i will just present this to my student...just a simple one

kathrine
Newbie Poster
3 posts since Jan 2011
Reputation Points: 10
Solved Threads: 1
 

hmmp...

kathrine
Newbie Poster
3 posts since Jan 2011
Reputation Points: 10
Solved Threads: 1
 

please for those who have a good heart....i just dont have enough time to do all..

kathrine
Newbie Poster
3 posts since Jan 2011
Reputation Points: 10
Solved Threads: 1
 

what does it mean?

omoridi
Junior Poster in Training
72 posts since Sep 2009
Reputation Points: 10
Solved Threads: 10
 

@Katherine, the reason why you are not getting any feedback is because you have hijacked someone else's thread. Your question does not even have any reference to the original question!

Please open your OWN thread and I promise we will try and help.

@Omiridi, please do not submit any replies on hijacked threads. Rather let the member open their own post, thanks.

AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You