?
Solved

LEFT function in VB 6.0

Posted on 2007-03-19
8
Medium Priority
?
1,370 Views
Last Modified: 2013-12-26
Please tell me how would I convert code below from VBA to VB6.0

A2=2367.25

(LEFT(INT(A2))+1)*(10^(LEN(INT(A2))-1))
0
Comment
Question by:Aiysha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18748389
what should the following part of the expression do:
(LEFT(INT(A2))+1)
because that is not valid.

please explain.
0
 
LVL 67

Expert Comment

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

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

may be what youre after?
0
 
LVL 86

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...
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Aiysha
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.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18748512
Try

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

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18748519
(LEFT(INT(4234),1)+1)*(10^(LEN(INT(4234))-1))
0
 
LVL 143

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
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 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
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

719 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