Solved

LEFT function in VB 6.0

Posted on 2007-03-19
8
1,366 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL VB connection works in one PC and doesn't in another 15 80
Problem to line 23 80
transition to visual .net from vb6 5 81
can this macro be converted to sub procedure 4 33
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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

738 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