Solved

LEFT function in VB 6.0

Posted on 2007-03-19
8
1,367 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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
Course of the Month4 days, 7 hours left to enroll

636 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