LEFT function in VB 6.0

Posted on 2007-03-19
Last Modified: 2013-12-26
Please tell me how would I convert code below from VBA to VB6.0


Question by:Aiysha
  • 3
  • 2
  • 2
  • +1
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18748389
what should the following part of the expression do:
because that is not valid.

please explain.
LVL 67

Expert Comment

ID: 18748396
Not sure what that command is supposed to do in vba...

a2 * 10^(len(a2)-1)

may be what youre after?
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 18748411
The Left() function is used to extract a certain number of characters from the Left side of a String.  In your example, it's use doesn't make any sense...

Can you explain in PLAIN ENGLISH what you are trying to compute?  ...and/or explain the process of computing it...
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.


Author Comment

ID: 18748460
left shoud take the leftmost character.. in my example about left should be 2.. Please paste this function in excel spreadsheet and see for your self what this function does..Its a way of rounding a number to its closest 1s,10s,100th, or 1000th..

Thank you.
LVL 67

Expert Comment

ID: 18748512

newString= left(int(a2),1) * (10^(len(int(a2))-1))
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18748519
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18748528
indeed, excel's LEFT takes 1 as default value for the lenght parameter.
vba does not have a default, hence you need to give that value explicitely
LVL 85

Accepted Solution

Mike Tomlinson earned 500 total points
ID: 18748537
Another one...

    Dim A2 As Double
    A2 = 2367.25
    Dim rounded As Integer
    rounded = (Left(A2, 1) + 1) * (10 ^ (Len(CStr(Int(A2))) - 1))
    Debug.Print rounded

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now