Solved

LEFT function in VB 6.0

Posted on 2007-03-19
8
1,361 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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 142

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 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...
0
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 67

Expert Comment

by:sirbounty
ID: 18748512
Try

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

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18748519
(LEFT(INT(4234),1)+1)*(10^(LEN(INT(4234))-1))
0
 
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
0
 
LVL 85

Accepted Solution

by:
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
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…

911 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

21 Experts available now in Live!

Get 1:1 Help Now