Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

function in vb.net

hello there,
Im trying to convert this little peace of code to vb.net can someone help me out please..
thanks
<?PHP
$checkthisnumber = 100;
$i=1;
while ($i < 151) 
{
        
 if ($i == $checkthisnumber) 
        {
                echo "number found,: ". $checkthisnumber;
		break;
        } else {
                echo $i." was not found";
        }
$i++;
}
 
?>

Open in new window

0
XK8ER
Asked:
XK8ER
1 Solution
 
Kevin CrossChief Technology OfficerCommented:
You could do this in a VB.NET sub like this:
'CheckNumber(100) <--- $checkthisnumber = 100;
Sub CheckNumber(ByVal number As Integer)
     Dim i As Integer = 1 '$i=1;
 
     While i < 151 'while ($i < 151) 
         If i = number Then 'if ($i == $checkthisnumber) 
             'echo "number found,: ". $checkthisnumber;
             Response.Write("number found,: " & CStr(number))
         Else 
             'echo $i." was not found";
             Response.Write(CStr(number) & " was not found")
         End
 
         i = i + 1 '$i++;
     End While
End Sub

Open in new window

0
 
Fernando SotoCommented:
Hi XK8ER;

This snippet should do the same thing.

Fernando

Dim checkthisnumber As Integer = 100
Dim i As Integer = 1
 
While i < 151
    If i = checkthisnumber Then
        Console.WriteLine("number found,: " & checkthisnumber.ToString())
    Else
        Console.WriteLine(i.ToString() & " was not found")
    End If
    i += 1
End While

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now