Random Number generator and verification problem - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners) +--- Thread: Random Number generator and verification problem (/Thread-Random-Number-generator-and-verification-problem) |
Random Number generator and verification problem - jinnah - 09-26-2012 In one of the fileds data needs to be between 10-99 and unique. For now I am trying the following codes Code: Dim upperbound, lowerbound Why does verification fail? Any other idea for generating 2 digits unique number? RE: Random Number generator and verification problem - Ankesh - 09-26-2012 Jinnah, Can you explain why are you using For loop. There is absolutely no need of this loop. You need to use randomize keyword before creating the random number. You can try any of the below options. Code: 1. Regards, Ankesh RE: Random Number generator and verification problem - jinnah - 09-26-2012 Hi Anikesh I see you are the best one in this forum. I think you already know my qtp skill. I have started learning it and using in my job at the same time. I just googled it and used it(For loop). Anyway, I will use your one as those are more Logical. Anyway, Anyidea how to verify if radom number is entered in the webedit box? RE: Random Number generator and verification problem - Ankesh - 09-27-2012 I see the comparison code by you is fine, it requires a slight modification though. Code: If Browser("...").Page("...").WebEdit("...").GetROProperty("value")=CatEventCode Then lets talk abt the above line. CatEventCode : This the random number generated. This is in integer format. Browser("...").Page("...").WebEdit("...").GetROProperty("value")= This will return the value in string format. so if you directly compare the value, result will be fail. You need to do the typecasting. correct code will be Code: strDisplayedValue=Browser("...").Page("...").WebEdit("...").GetROProperty("value") 'get the value Regards, Ankesh RE: Random Number generator and verification problem - jinnah - 09-28-2012 Waooo Man! I see I am learning. I don't know how long you will support me in thsi way. I am already in love of this site and ofcourse you!! Ha haa. Yes, I had problem with verification. I used same method you taught me for Reg Ex verification. I did. ----------------------------------------------------------- Code: upperbound=99 But I am going to replace these with your new codes.It is more logical and I ve just learned a new thing. Great buddy. Thanks again. Hi, I am sorry as my reply goes on top of yours. I think I need to reply from Quick Reply section. So to covert string to Intiger Cint is used. What about Intiger to string? Sorry for dumb question. Yes bro! I have just changhed my previous codes. IT works fine. Thanks again Here it is Code: upperbound=99 |