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 7081207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:53:28+00:00 2026-05-28T06:53:28+00:00

I want to know what exactly are the differences between CStr() , Str() and

  • 0

I want to know what exactly are the differences between CStr(), Str() and .ToString()?

Label1.Text = CStr(Int(Rnd() * 10))

and

Label1.Text = Str(Int(Rnd() * 10))

and

Label1.Text = Int(Rnd() * 10).ToString

If I use this condition:

If Label1.Text = "7" Then
     'Some code here
End If

Str() doesn’t work here. What’s the difference?

  • 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-05-28T06:53:28+00:00Added an answer on May 28, 2026 at 6:53 am

    ToString will call the .ToString() function on a particular instance.
    In practice, this means that it will throw an exception if the object in
    question is Nothing. However, you can implement .ToString() in your own
    classes to get a useful string representation of your object, whereas
    CType/CStr only work with built-in classes and interfaces.

    CStr and CType(expression, String) are exactly equivalent (I’m not
    sure where the other poster got the idea that CStr is faster). But they
    aren’t really functions, they’re compiler directives that will emit very
    different code depending on the declaration of expression. In most
    cases, these directives call a bunch of internal VB code that tries to
    get a reasonable string out of expression.

    DirectCast(expression, String) assumes that the expression in
    question really is a String and just casts it. It’s the fastest of all
    these options, but will throw an exception if expression is anything
    other than a String.

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

Sidebar

Related Questions

I want to know what exactly is the difference between CLR & CLI? From
I know why I want to use private virtual functions, but how exactly can
I want to know what exactly is the sequence of calls that occurs when
I want to know how to use variables for objects and function names in
I want to know what is exactly AJAX heartbeat pattern and what is the
I know that you can use boost serialization to serialize to a text format
I just want to know the difference between: sort < output and sort output
I want to know what is the difference between web application and web site
Want to know what the stackoverflow community feels about the various free and non-free
want to know why String behaves like value type while using ==. String s1

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.