Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If within select statement
#1
Solved: 11 Years, 4 Months ago
Hi all here is my requirement:
Mainly two parameters(list boxes) involved 1)Preferred Phone and 2)Preferred communication.
Preferred phone has : Home Phone,Mobile and Work Phone
Preferred comm has : Phone, Email and Fax

Myrequirement: When preferred comm is set as 'Phone' then depending on the 'preferred phone' selection, data is set in the respective fields. Example: When preferred comm is 'phone' and preferred phone is 'Mobile' then set the mobile number in the mobile field.

My code here describes if statement with in select statement.. can I define so? as I see if statements arent working. Please suggest!!!!

Code:
PrefPhone = inputbox("Enter Preferred Phone")
Browser("TalonPro Solutions").Page("TalonPro Solutions_3").WebList("Preferred Phone").Select PrefPhone
PrefCom = inputbox("Enter PreferredComm")
Browser("TalonPro Solutions").Page("TalonPro Solutions_3").WebList("preferred contact").Select PrefCom
pref_com = Browser("TalonPro Solutions").Page("TalonPro Solutions_3").WebList("preferred contact").GetROProperty("selection")

Select Case pref_com
Case "Email"
Browser("TalonPro Solutions").Page("TalonPro Solutions_3").WebEdit("ctl00$ContentPlaceHolder1$txtE").Set "swetha.b@osmosys.asia"
Case "Phone"
If PrefCom = "Home Phone" Then
Browser("TalonPro Solutions").Page("TalonPro Solutions_4").WebEdit("ctl00$ContentPlaceHolder1$txtH").Set "(998)876-4534"
elseif PrefCom = "Mobile" Then
Browser("TalonPro Solutions").Page("TalonPro Solutions_5").WebEdit("ctl00$ContentPlaceHolder1$txtM").Set "(987)876-2345"
else
Browser("TalonPro Solutions").Page("TalonPro Solutions_3").WebEdit("ctl00$ContentPlaceHolder1$txtWorkPhone").Set ("(987)765-7654)")
    End If
Browser("TalonPro Solutions").Page("TalonPro Solutions_3").WebEdit("ctl00_ContentPlaceHolder1_txtWorkPhone").Set ("(987)765-7654)")
Case "Fax"
Browser("TalonPro Solutions").Page("TalonPro Solutions_5").WebEdit("ctl00$ContentPlaceHolder1$txtF").Set "(987)564-3452"
End Select
Reply
#2
Solved: 11 Years, 4 Months ago
Yes you can use the if statement in that way, also I dont see any problem with your code, are you getting any error?

Please paste properly formatted code. use tags, this helps to go through the code easily.

Reply
#3
Solved: 11 Years, 4 Months ago
hi Swethaaaaaaa,

See you code below for Case phone

Code:
Case "Phone"
If PrefCom = "Home Phone" Then
Browser("TalonPro Solutions").Page("TalonPro Solutions_4").WebEdit("ctl00$ContentPlaceHolder1$txtH").Set "(998)876-4534"
elseif PrefCom = "Mobile" Then
Browser("TalonPro Solutions").Page("TalonPro Solutions_5").WebEdit("ctl00$ContentPlaceHolder1$txtM").Set "(987)876-2345"
else
Browser("TalonPro Solutions").Page("TalonPro Solutions_3").WebEdit("ctl00$ContentPlaceHolder1$txtWorkPhone").Set ("(987)765-7654)")
End If
Browser("TalonPro Solutions").Page("TalonPro Solutions_3").WebEdit("ctl00_ContentPlaceHolder1_txtWorkPhone").Set ("(987)765-7654)")


After End if you have work phone selected.
Remove that and Try


Thanks

Try this code

Code:
Case "Phone"
If PrefCom = "Home Phone" Then
Browser("TalonPro Solutions").Page("TalonPro Solutions_4").WebEdit("ctl00$ContentPlaceHolder1$txtH").Set "(998)876-4534"
elseif PrefCom = "Mobile" Then
Browser("TalonPro Solutions").Page("TalonPro Solutions_5").WebEdit("ctl00$ContentPlaceHolder1$txtM").Set "(987)876-2345"
elseif PrefCom = "WorkPhone"
Browser("TalonPro Solutions").Page("TalonPro Solutions_3").WebEdit("ctl00$ContentPlaceHolder1$txtWorkPhone").Set ("(987)765-7654)")
End If
Reply
#4
Solved: 11 Years, 4 Months ago
@Nilesh - even though the statement is there it should not cause any issue. isn't it?

also always paste the formatted code using proper tags and do take care while pressing your 'a' key.

Reply
#5
Solved: 11 Years, 4 Months ago
New code forgot to add Then in code , you can try this

Code:
Case "Phone"
If PrefCom = "Home Phone" Then
Browser("TalonPro Solutions").Page("TalonPro Solutions_4").WebEdit("ctl00$ContentPlaceHolder1$txtH").Set "(998)876-4534"
elseif PrefCom = "Mobile" Then
Browser("TalonPro Solutions").Page("TalonPro Solutions_5").WebEdit("ctl00$ContentPlaceHolder1$txtM").Set "(987)876-2345"
elseif PrefCom = "WorkPhone" Then
Browser("TalonPro Solutions").Page("TalonPro Solutions_3").WebEdit("ctl00$ContentPlaceHolder1$txtWorkPhone").Set ("(987)765-7654)")
End If
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using Range in Select Case Statement Studymode 0 1,510 12-14-2017, 06:18 PM
Last Post: Studymode
  Using Select Case Statement Studymode 0 11,722 12-13-2017, 05:55 AM
Last Post: Studymode

Forum Jump:


Users browsing this thread: 1 Guest(s)