Results 1 to 9 of 9

Thread: Pubic Sub Blah( Need Help here ?? ) [Resolved]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Resolved Pubic Sub Blah( Need Help here ?? ) [Resolved]

    Ok here is my code.
    [code
    Public Sub NxAxMxE4( ????? )
    Dim str As String
    Dim x As Integer

    str = Mid(Word, 1, 1) & Base & Mid(Word, 2, 1) & Base & Mid(Word, 3, 1) & Base & Mid(Word, 4, 1)
    If Len(str) <= 32 Then
    lstGen.AddItem str
    End If

    End Sub
    [/code]

    Ok where Base is, that is going to be a letter or letters. I want to be able to call it using a different letter.

    Call NxAxMxE4 (xx)
    So then Base will equal xx

    Call NxAxMxE4 (vv)
    So then Base will equal vv


    How i do this ??
    Last edited by Ricky1; Jun 8th, 2005 at 03:27 PM.
    Im Learning !!!!

  2. #2
    Fanatic Member Blade's Avatar
    Join Date
    Jan 1999
    Location
    Stoke-on-Trent, UK
    Posts
    527

    Re: Pubic Sub Blah( Need Help here ?? )

    like this:
    VB Code:
    1. Public Sub NxAxMxE4([b]ByVal Base As String[/b])
    2. Dim str As String
    3. Dim x As Integer
    4.  
    5. str = Mid(Word, 1, 1) & Base & Mid(Word, 2, 1) & Base & Mid(Word, 3, 1) & Base & Mid(Word, 4, 1)
    6. If Len(str) <= 32 Then
    7. lstGen.AddItem str
    8. End If
    9.  
    10. End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Pubic Sub Blah( Need Help here ?? )

    damn i was missing the ByVal bit of.
    Im Learning !!!!

  4. #4
    Fanatic Member Blade's Avatar
    Join Date
    Jan 1999
    Location
    Stoke-on-Trent, UK
    Posts
    527

    Re: Pubic Sub Blah( Need Help here ?? )

    If you miss the ByVal off then it defaults to ByRef which still would have worked.

    The reason I chose ByVal is because you are not modifying the contents of Base, only reading it.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Pubic Sub Blah( Need Help here ?? )

    doesn't seem to be working
    Im Learning !!!!

  6. #6
    Fanatic Member Blade's Avatar
    Join Date
    Jan 1999
    Location
    Stoke-on-Trent, UK
    Posts
    527

    Re: Pubic Sub Blah( Need Help here ?? )

    What's not working?

    How are you calling the sub and what are you passing to it?

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Pubic Sub Blah( Need Help here ?? )

    Code:
    Public Sub NxAxMxE4(ByVal Base As String)
    Dim str As String
    Dim x As Integer
    
    str = Mid(Word, 1, 1) & Base & Mid(Word, 2, 1) & Base & Mid(Word, 3, 1) & Base & Mid(Word, 4, 1)
    If Len(str) <= 32 Then
        lstGen.AddItem str
    End If
    
    End Sub
    Calling It With This.

    Code:
    Public Sub Generate()
    For I = 0 To lstBase.ListCount - 1
    Word = lstBase.List(I)
    Call NxAxMxE4(xx)
    Next I
    End Sub
    So If List(i) was Rick i shud get RxxIxxCxxK
    Im Learning !!!!

  8. #8
    Fanatic Member Blade's Avatar
    Join Date
    Jan 1999
    Location
    Stoke-on-Trent, UK
    Posts
    527

    Re: Pubic Sub Blah( Need Help here ?? )

    you need to put quotes around the xx
    ie:
    VB Code:
    1. Call NxAxMxE4("xx")

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Pubic Sub Blah( Need Help here ?? )

    SWeeeeeeeeeeeeeeeeeeeeeeet

    Thanks Bro.
    Im Learning !!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width