Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Count the number of 3 number appers between 0-3333
#1
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi,

Could some one please tell me how to count occurence of 3digit between 3 and 3333.
I tried with the following code I am getting the numbers which contain 3 in the number but problem comes when there is number like (3000) which prints 4 times since length of the number (3000) is 4.

Code:
For i=3 to 3333
temp=i
While temp>0
  d=instr(temp,3)
  If (d <> 0) Then
     c = c+1
     print(i)
  End If
temp = temp/10
temp = Fix(temp)
Wend
Next
Print(c)
Reply
#2
Solved: 11 Years, 3 Months, 4 Weeks ago
Why wouldn't you try this? If the answer is 1336, then this works.

Code:
for i = 1 to 3333
    for j = 1 to len(Cstr(i))
        if Asc(Mid(CStr(i),j,1)) = 51 Then
        iCnt = iCnt+1
        End If
    Next
Next
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Web Object Unique ID Number zunebuggy 0 1,556 07-10-2017, 05:37 PM
Last Post: zunebuggy
  VB Script to count number of links in a web page. Suma Parimal 4 25,257 07-01-2015, 12:59 PM
Last Post: govind
  Keep row number imbizile 0 2,751 09-18-2014, 03:31 AM
Last Post: imbizile
  Retrieve row number based on value in DataTable marfa 6 30,725 07-31-2014, 08:36 PM
Last Post: dharshinishankari@gmail.com
  Create a random number starting with an alphabet QTPmate 4 4,161 07-31-2014, 09:29 AM
Last Post: QTPmate

Forum Jump:


Users browsing this thread: 1 Guest(s)