MajorGeeks Support Forums

Go Back   MajorGeeks Support Forums > ----------= PC, Desktop and Laptop Support =---------- > Software
Register FAQ Members List Calendar Casino Mark Forums Read

Software Software such as operating systems like Windows XP, Windows Vista, Windows 7 etc., or specific programs.


Reply
 
Thread Tools Display Modes
  #1  
Old 10-30-03, 09:30
Panther007 Panther007 is offline
Private E-2
 
Join Date: Oct 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Cool Module in VB

I have tried this module and what is happening is that It cuts off the last number and still gives me the last digit of all Alpha Ex:

thisis the total number
168577 or 114536A

this is the ParseNumeric code which cuts off the last digit
16857 or 117711

this is the ParseAlpha which still puts in numeric data as well
7 or A

Option Compare Database
Option Explicit

Function ParseAlpha(ByVal Mystring As String) As String

ParseAlpha = Right(Mystring, 1)

End Function

Function ParseNumeric(ByVal Mystring As String) As Single

ParseNumeric = Left(Mystring, Len(Mystring) - 1)

End Function

'**********************************************************************************************

Public Sub Test()

'the following goes into the form event code or wherever.
'to get the separate values follow the example below.

Dim MyStringValue
MyStringValue = "123456A" '*arbitrary variable just to test with make sure you dim the variable properly.

ParseAlpha (MyStringValue)
ParseNumeric (MyStringValue)
Reply With Quote
Sponsored links
  #2  
Old 10-30-03, 09:37
Kodo's Avatar
Kodo Kodo is offline
SNATCHSQUATCH
 
Join Date: Jan 2002
Location: Syracuse NY, USA
Posts: 11,502
Thanks: 17
Thanked 72 Times in 49 Posts
Default

this is why I made it modular.. don't call the function if it doesn't have any alphanumeric character.. for that we will need to test .

something I didn't know when I wrote the functions was that you'd have values that DIDN'T have an alpha at the end.

I'll be right back with updated code.
__________________
"The American people will never knowingly adopt Socialism..." -Norman Thomas
Reply With Quote
  #3  
Old 10-30-03, 10:34
Kodo's Avatar
Kodo Kodo is offline
SNATCHSQUATCH
 
Join Date: Jan 2002
Location: Syracuse NY, USA
Posts: 11,502
Thanks: 17
Thanked 72 Times in 49 Posts
Default

ok..I've determined that I'm going to shoot verizon.. my internet connection has gone down today more than a prom queen.

any way.. on to the goods.

this is the NEW module. toss out or over write the old one with this one.

---------------------------------------------------------------------------------
PHP Code:
Function ParseAlpha(ByVal Mystring As Variant) As String
    
If IsNumeric(MystringThen
        AlphaValue 
Mystring
    
Else
        
AlphaValue Right(Mystring1)
    
End If
    
ParseAlpha AlphaValue
End 
Function

Function 
ParseNumeric(ByVal Mystring As String) As Single
NumericValue 
Left(MystringLen(Mystring) - 1)
ParseNumeric NumericValue
End 
Function 
---------------------------------------------------------------------------------


here is your call to it.


PHP Code:
Dim MyStringValue As String
MyStringValue 
"123456" '*arbitrary variable just to test with

Dim AlphaValue As Variant
Dim NumericValue As Single

AlphaValue = ParseAlpha(MyStringValue)

If Not IsNumeric(AlphaValue) Then
     NumericValue = ParseNumeric(MyStringValue)
End If
Debug.Print AlphaValue & " " & NumericValue 
I put the debug.print in there so you can see the values that are returned in the IDE's "immediate window"
__________________
"The American people will never knowingly adopt Socialism..." -Norman Thomas
Reply With Quote
  #4  
Old 10-30-03, 11:43
Panther007 Panther007 is offline
Private E-2
 
Join Date: Oct 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Module

I'm so sorry. But this is what I'm trying to do I wasn't quit clear
on my explanation I do apologize.
I need for Supp Issue the entire number is needed it shouldn't cut it off..

For the Issue I need just the Alph not the numeric value for
replacement of the numeric value it can be N/A



Supp Issue: ParseNumeric([Test Table]![WOT Order Tool Number])

Issue: ParseAlpha([Test Table]![WOT Order Tool Number])


WOT Order Tool |Supp Issue | Issue |
----------------------------------------------------------------
| 114536A | 114536 | A |
----------------------------------------------------------------
| 117711A | 117711 | A |
----------------------------------------------------------------
| 134234C | 134234 | C |
----------------------------------------------------------------
| 138748A | 138748 | A |
----------------------------------------------------------------
| 157217B | 157217 | B |
----------------------------------------------------------------
| 167652B | 167652 | B |
----------------------------------------------------------------
| 168577 | 16857 | 168577 N/A |
----------------------------------------------------------------
| 168578 | 16857 | 168578 N/A |
----------------------------------------------------------------
Reply With Quote
  #5  
Old 10-30-03, 11:53
Kodo's Avatar
Kodo Kodo is offline
SNATCHSQUATCH
 
Join Date: Jan 2002
Location: Syracuse NY, USA
Posts: 11,502
Thanks: 17
Thanked 72 Times in 49 Posts
Default

then your call should be the following..

PHP Code:
MyStringValue "123456" '*arbitrary variable just to test with

Dim AlphaValue As Variant
Dim NumericValue As Variant


AlphaValue = ParseAlpha(MyStringValue)

If Not IsNumeric(AlphaValue) Then
     NumericValue = ParseNumeric(MyStringValue)
     Else
     NumericValue = "N/A"
End If
Debug.Print AlphaValue & " " & NumericValue 


here's a sample of the data that I input to test
123456
and
12345A

if WOTOT=123456 is entered then the value that returns is
123456 and N/A

for 12345A it returns

12345 and A (split from the 12345. )
__________________
"The American people will never knowingly adopt Socialism..." -Norman Thomas
Reply With Quote
Sponsored links
  #6  
Old 10-30-03, 14:18
Panther007 Panther007 is offline
Private E-2
 
Join Date: Oct 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Cool Module

Thank you so much I had to play with the code a bit now it works perfectly. Thanks for all your help.


Function ParseAlpha(ByVal Mystring As Variant) As String

If IsNumeric(Mystring) Then
AlphaValue = "N/A"
Else
AlphaValue = Right(Mystring, 1)
End If
ParseAlpha = AlphaValue
End Function
Reply With Quote
  #7  
Old 10-30-03, 14:20
Kodo's Avatar
Kodo Kodo is offline
SNATCHSQUATCH
 
Join Date: Jan 2002
Location: Syracuse NY, USA
Posts: 11,502
Thanks: 17
Thanked 72 Times in 49 Posts
Default

glad it worked out for you
__________________
"The American people will never knowingly adopt Socialism..." -Norman Thomas
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 14:54.

MajorGeeks.Com Menu

MajorGeeks.Com \ All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ NEW! PC Games \ System Tools \ Macintosh \ Demonews.Com \ Top Downloads

MajorGeeks.Com \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds


All content Copyright MajorGeeks.com source code Powered by vBulletin® Version 3.8.4
Copyright © 2009 vBulletin Solutions, Inc. All rights reserved.
Ad Management by RedTyger