PDA

View Full Version : Solved: Simple math and removing chars but not working



Trevor
03-29-2008, 10:41 PM
I am trying to remove the first 3 chars of a string [text1] I have tried:

Me.[Text2] = Left(Text1, -3) 'and also tried
Me.[Text2] = Left((Text1), -3)
' both with no luck


The second question is math not working, I am trying to add 2 text boxes together that both contain #'s but instead of add it is concatinating for some reason:

[Text4] = Text5 + text6 'I have also tried
[Text4] = (Text5) + (Text6]
'ie: 5+5 should give me 10 not 55

Thanks for helping

orange
03-30-2008, 06:58 AM
I am trying to remove the first 3 chars of a string [text1] I have tried:

Me.[Text2] = Left(Text1, -3) 'and also tried
Me.[Text2] = Left((Text1), -3)
' both with no luck

The second question is math not working, I am trying to add 2 text boxes together that both contain #'s but instead of add it is concatinating for some reason:

[Text4] = Text5 + text6 'I have also tried
[Text4] = (Text5) + (Text6]
'ie: 5+5 should give me 10 not 55
Thanks for helping

The left(string,int) function picks up the leftmost chars.
I think you want

Me.text2 =Mid(Me.Text1,4)
which will take positions 4 thru the fulll length of
Me.Text1 and place it in Me.Text2

For the math thing
you may try
Text4 = Val(Text5) +Val(Text6)

Look up the val() function. Also take a look at Mid()

Trevor
03-30-2008, 10:18 AM
Ok thanks will do, the left and mid is a little confusing because the int still reffers to same position in the string , I think thdy would both take positiion at the int.

Trevor
03-30-2008, 01:04 PM
I am trying to covert a hex # to a base10 using

078bfbff00000fc0 = 4032 '(0+7+8+12+15+12+15+15+0+0+0+0+0+15+13+0) is this correct or is my math off)
I am using

Text3 = Val("&h" & CPUID) ' it doesn't seem right that the # should be 4032, I think it should be about 112

thanks for helping

Trevor
03-30-2008, 01:45 PM
trying now to covert dec to hex , dec is a numeric value, since I hmve converted it from hex to dec , now that I minipulated it I want to convert it back to hex I have tried

Dim number as string
Hex(number) ' number is the var holding the number string to convert to hex

orange
03-30-2008, 06:50 PM
Ok thanks will do, the left and mid is a little confusing because the int still reffers to same position in the string , I think thdy would both take positiion at the int.

Trevor,
I have no idea what your message means?
Left and Mid are for manipulating strings.

Trevor
03-30-2008, 08:06 PM
ok, thanks for the reply, but I solved this a few hours ago, the site seems to be running slow today, but Instead of converting the string number to hex I converted it to Oct, the use of Mid, left and right was because I was trying to only perform the operation on part of the string, but seaperated the string in the different parts and placed then backed together in a different order, so the resulting # looks nothing like the source it came from.

Trevor
03-30-2008, 08:06 PM
ok, thanks for the reply, but I solved this a few hours ago, the site seems to be running slow today, but Instead of converting the string number to hex I converted it to Oct, the use of Mid, left and right was because I was trying to only perform the operation on part of the string, but seaperated the string in the different parts and placed then backed together in a different order, so the resulting # looks nothing like the source it came from.