|
-
Jun 22nd, 2000, 11:04 AM
#1
Thread Starter
Lively Member
I am making an inventory program and the numbers entered will be of varying lengths. I need to remove the last two digits on the right of the number, but can't use the Left function since the length of the numbers will change over time.
-
Jun 22nd, 2000, 11:12 AM
#2
transcendental analytic
I don't think theres a problem with that:
Code:
var=left(var,len(var)-2)
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 22nd, 2000, 11:13 AM
#3
Ok this ones easy
If using vb 5 or 6 then use the Right function.
-
Jun 22nd, 2000, 11:24 AM
#4
transcendental analytic
Jethro, are you sure that's a good idea?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 22nd, 2000, 11:35 AM
#5
Of course
The Right function works fine if you know the exact number of characters you want to extract. If a fraction maybe a string extract based around the point, this allows variable character extraction.
Am using vb5, so don't know if any bad effects in 4 or below, and am waiting to complete work today at this site to load 6. But persumably the Right function works the same in 6 as it does in 5.
Why have you found a problem with it?
-
Jun 22nd, 2000, 11:44 AM
#6
transcendental analytic
It wont solve his problem:
123456 -> 1234
not
3456
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 22nd, 2000, 11:46 AM
#7
Thread Starter
Lively Member
why?
If I do this and put in 12345, it returns 1234.
Private Sub Command1_Click()
Dim Var
Var = Text1.Text
Var = Left(Var, Len(Var) - 2)
Text2.Text = Var
End Sub
This will return 123, what I want.
Private Sub Command1_Click()
Dim Var
Var = Val(Text1.Text)
Var = Left(Var, Len(Var) - 2)
Text2.Text = Val(Var)
End Sub
Am I doing the Val() right? I only need whole numbers.
-
Jun 22nd, 2000, 11:54 AM
#8
transcendental analytic
so that's what you want:
Code:
Text2.Text=int(text1.text/100)
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 22nd, 2000, 11:57 AM
#9
Ok this is confused
You stated you wanted to extract the last two digits, are you really saying you want to extract the full amount excluding the fractions
If so the data would be something like
1234.56
In vb6 use the split function in vb5 use instr and mid functions, or kedamans approach.
-
Jun 22nd, 2000, 12:04 PM
#10
Thread Starter
Lively Member
Thanks Kedaman
Thank you, both ways will work for me. Sorry for the confusing wording. I should have gave an example.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|