how do i convert this code to VB? i am new in VB.Pls help.

ABC (int xyz)
{
    If xyz==0
    {
    return(0)
    }
    else
    {
    return (xyz + ABC(xyz-1));
    }
}

Recommended Answers

All 2 Replies

Something like this should work:

Private Function ABC(ByVal xyz As Integer) As Integer
    If xyz = 0 Then
        ABC = 0
    Else
        ABC = xyz + ABC(xyz - 1)
    End If
End Function

It's hard to be 100% sure since the code you submitted isn't consistent, and you haven't mentioned what exactly you're trying to do with the code. However it does look like you're trying get the sum of all the digits preceding the input down to 0. If that is the case this code will work. For instance inputting a value of 10 produces an output of 55.

thank you tinstaafl

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.