+ Reply to Thread
Results 1 to 3 of 3

CStr Question

  1. #1
    Registered User
    Join Date
    10-23-2006
    Posts
    79

    Question CStr Question

    Hi

    I am learning Excel VBA (teaching myself and not being very good at it).

    I have a query on CStr - in the example below, it is used for the Msgbox - but when I put the second MsgBox line in (as I couldn't see why it is needed in the example), it returns the same result.

    Please Login or Register  to view this content.
    So my question is - why/what example would you use it..????

    Can someone explain it to me..(in laymans/simple terms please as i am not a computer techie!)?

    Thanks, dugong

    p.s. I have looked at the help and it does not explain it satisfactorily either!

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    You would use it to convert a variable or constant to String type.

    What may appear confusing is that the msgbox function works the same regardless of your use of the CSTR funciton. This is because VBA conveniently does the conversion for you automatically.

    By using it you are telling the compiler exactly what you want to happen rather than letting it make assumptions.
    This also makes the intention clearer when you or somebody else reviews the code at a later date.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    10-23-2006
    Posts
    79

    Thanks

    Thanks Andy - once again you have come to my rescue!

    Sometimes it takes that extra explanation to clear the mud! :o

    dugong

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1