Click here to Skip to main content
15,918,808 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:


I have this code in PHP and I want to write it in Vb.net
PHP
for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
        $difference /= $lengths[$j];
    }


I have made it to look like this to my knowlegde


VB
Dim d As Integer
          For d = 0 To (date_diff >= lengths(d) AndAlso d < lengths.Count - 1)
           date_diff /= lengths(d)
           d += 1
       Next





and the error that I am getting is :

Overload resolution failed because no Public '>=' can be called with these arguments:
'Public Shared Operator >=(t1 As System.TimeSpan, t2 As System.TimeSpan) As Boolean':
Argument matching parameter 't2' cannot convert from 'String' to 'TimeSpan'.



I want to achieve something the CodeProject Post time like "Posted 2 minutes ago" ,
if anyone have a similar example please help.
Posted
Updated 30-Apr-11 23:32pm
v2

You can't use a boolean in a for loop. You're effectively doing this:

VB
for d = 0 to false (or true)
...


Next, you're incrementing the control variable d inside the loop - this goes WAY beyond bad programming practice.

Finally, we can't help you convert it if we don't know the types of the variables being use.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 1-May-11 18:08pm    
Nonsense detected! My 5.
--SA
Visual Basic For...Next loops are fundamentally different from PHP/C/C++ for() statements. You must use a While...End While or Do...Loop statement in VB in order to use a boolean statement as the looping condition.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900