Module

Discussion in 'Software' started by Panther007, Oct 30, 2003.

  1. Panther007

    Panther007 Private E-2

    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)
     
  2. Kodo

    Kodo SNATCHSQUATCH

    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.
     
  3. Kodo

    Kodo SNATCHSQUATCH

    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:
    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:
    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"
     
  4. Panther007

    Panther007 Private E-2

    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 |
    ----------------------------------------------------------------
     
  5. Kodo

    Kodo SNATCHSQUATCH

    then your call should be the following..

    PHP:
    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. )
     
  6. Panther007

    Panther007 Private E-2

    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
     
  7. Kodo

    Kodo SNATCHSQUATCH

    glad it worked out for you ;)
     

MajorGeeks.Com Menu

Downloads 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 \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

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