[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1378
  • Last Modified:

LEFT function in VB 6.0

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
Aiysha
Asked:
Aiysha
  • 3
  • 2
  • 2
  • +1
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what should the following part of the expression do:
(LEFT(INT(A2))+1)
because that is not valid.

please explain.
0
 
sirbountyCommented:
Not sure what that command is supposed to do in vba...

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

may be what youre after?
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
AiyshaAuthor Commented:
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
 
sirbountyCommented:
Try

newString= left(int(a2),1) * (10^(len(int(a2))-1))
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
(LEFT(INT(4234),1)+1)*(10^(LEN(INT(4234))-1))
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now