Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8239735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:14:47+00:00 2026-06-07T20:14:47+00:00

I need the following function converted to VB.NET, but I’m not sure how to

  • 0

I need the following function converted to VB.NET, but I’m not sure how to handle the statement

res = (uint)((h * 0x21) + c);

Complete function:

private static uint convert(string input)
{
    uint res = 0;
    foreach (int c in input)
        res = (uint)((res * 0x21) + c);
    return res;
}

I created the following, but I get an overflow error:

Private Shared Function convert(ByVal input As String) As UInteger

    Dim res As UInteger = 0
    For Each c In input
        res = CUInt((res * &H21) + Asc(c)) ' also tried AscW 
    Next
    Return res

End Function

What am I missing? Can someone explain the details?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T20:14:49+00:00Added an answer on June 7, 2026 at 8:14 pm

    Your code is correct. The calculation is overflowing after just a few characters since res increases exponentially with each iteration (and it’s not the conversion on the character that’s causing the overflow, it’s the unsigned integer that overflows).

    C# by default allows integer operations to overflow – VB doesn’t. You can disable the overflow check in the project settings of VB, though. However I would try not to rely on this. Is there a reason this particular C# has to be ported? After all, you can effortlessly mix C# and VB libraries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need following function (from C++ dll) available in C++/CLI extern C _declspec(dllexport) void
can someone help with this? I need the following function to do this... $x
I need the following C function in Python: int func(Uint8 *bytRecvBuffer, int *iRecvLen); I
I need to sort string, and I came up with the following function. def
I need to check if an object contains any value. The following function works
I need a function with the following signature: System.Reflection.PropertyInfo getPropertyInfo(System.Type type, string NavigationPath) or
I need to add fade function in the following script. I need that the
I need to call a function in the following fashion: var f = 'fadeOut';
I need a VBA function that will perform the following: Find all unique values
Morning- I need a function that would produce the following kind of looking sequence:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.