Results 1 to 25 of 25

Thread: [RESOLVED] Writing (advanced?) functions?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Resolved [RESOLVED] Writing (advanced?) functions?

    There are functions provided within VB that let you do things like uniq([a-z])...by that I mean putting "[a-z]" rather than having to enclose in speech marks. If I was currently to make a function like this, I would have to use uniq("[a-z]") and parse the info within the speech marks, but I am wondering if there's any way around this :-)
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  2. #2
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Writing (advanced?) functions?

    What do you mean by "speech marks" ? do you mean quotes ?

    I think you might refraze your question, becasue I don't understand anything from what you are saying there...

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: Writing (advanced?) functions?

    A speech mark is a "...a quotation mark...a double of '

    Normally when I send a string in a function I would need to enclose the string within these speech marks thus: uniq("[a-z]")

    I would like to know if there's any way to do it thus: uniq([a-z])

    I think I made the original question clear enough, personally :-P
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  4. #4
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Writing (advanced?) functions?

    Quote Originally Posted by smUX
    A speech mark is a "...a quotation mark...a double of '

    Normally when I send a string in a function I would need to enclose the string within these speech marks thus: uniq("[a-z]")

    I would like to know if there's any way to do it thus: uniq([a-z])

    I think I made the original question clear enough, personally :-P

    Believe me, your second post was MUCH clearer.


    As for whether you can do that or not, I don't believe you can. The reason there are quotes around the parameter being sent in, is because it is a string field. If it were accepting a number, using uniq(1) would work fine.

    Trying to throw a string in without quotes would create an error while parsing the code, as the compiler would try to find the variable associated with the value you're trying to add in.


    HTH

  5. #5
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Writing (advanced?) functions?

    im with CVMichael - that first post was confusing.. lol

    but now it makes sense....

    well.. the closest thing I think u could do would be to create a const or an enum..

    VB Code:
    1. Public Const az = "[a-z]"

    or if u use the enum u can pick it from a list...
    VB Code:
    1. Public Enum strPass
    2.     UpperA_Z = "[A-Z]"
    3.     Lowera_z = "[a-z]"
    4. End Enum
    5.  
    6. Public Sub Test(passedin As strPass)
    7.  
    8.  
    9. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: Writing (advanced?) functions?

    Using a const could work, actually...do you see why I am trying to do it? I plan to be making a few functions and I want to make them as easy to use as normal VB functions...can't remember one off hand but I'm sure people know what I am on about :-)
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  7. #7
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Writing (advanced?) functions?

    then Use the ENUM
    that way when u type the function name u will get a dropdown of choices for the function - use that code i posted.. then type Test( and you'll see..
    very conveinient
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  8. #8
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Writing (advanced?) functions?

    you can't do an Enum like that Static, it's an ENUMeration, not an ESTRINGeration

  9. #9
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Writing (advanced?) functions?

    uhhhh.. oops he he

    sorry.. its early and i havent had enough coffee yet.
    i'll go hide in the corner until im awake

    "Pay no attention to the man behind the curtain!"






    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  10. #10
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Writing (advanced?) functions?

    Quote Originally Posted by smUX
    Using a const could work, actually...do you see why I am trying to do it? I plan to be making a few functions and I want to make them as easy to use as normal VB functions...can't remember one off hand but I'm sure people know what I am on about :-)
    Not me...

  11. #11
    Lively Member
    Join Date
    Jun 2006
    Location
    Israel, Beer-Sheva
    Posts
    65

    Re: Writing (advanced?) functions?

    Quote Originally Posted by penagate
    Not me...
    sMux wants to create functions like that:

    Debug.Print "Af23" Like "[A-Z][a-z]##"

    But even this particular function requires quote marks.
    I can't recall one that uses [a-z] without the quote marks, can you point to a specific one?

    All I can think of is this:
    VB Code:
    1. Option Explicit
    2. Dim StringsArr As Variant
    3.  
    4. Public Enum strPass
    5.     UpperA_Z = 1
    6.     Lowera_z = 0
    7. End Enum
    8.  
    9. Public Sub Test(passedin As strPass)
    10.     Select Case StringsArr(passedin)
    11.         Case "[a-z]"
    12.             '..
    13.         Case "[A-Z]"          ''CIRCULAR coding, convert to number, then  
    14.                                    ''conert to string again :\ useless
    15.             '..
    16.     End Select
    17. End Sub
    18.  
    19. Private Sub Form_Load()
    20.     StringsArr = Array("[a-z]", "[A-Z]")
    21.  
    22.     Test UpperA_Z
    23. End Sub

    Kinda useless, maybe I got you wrong?
    Last edited by MishaSoft3d; Jun 9th, 2006 at 09:17 AM.
    "Creativity is knowing how to hide your sources" / Albert E.



    Yeahh babè

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: Writing (advanced?) functions?

    No, I can't think of one offhand...I am almost sure I have seen them though...although LIKE sounds familiar enough to be it...maybe I'm mistaken :-)
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  13. #13
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Writing (advanced?) functions?

    No, it's syntatically impossible.

  14. #14
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Writing (advanced?) functions?

    don't you mean 'syntactically' - what a ridiculous word

  15. #15
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Writing (advanced?) functions?

    Leave me alone, I'm not the forum spellchecker any more

  16. #16

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: [RESOLVED] Writing (advanced?) functions?

    Thank God :-P

    And Bush, watch out, I'm a perfect speller and could point out your errors :-P

    Worse still, I could point you to http://www.vbforums.com/showpost.php...64&postcount=8 and inform you that when you're mentioning someone's name in conversation like that you should have a comma both before and after the name :-P
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  17. #17
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: [RESOLVED] Writing (advanced?) functions?

    i just like how hard syntactically is to pronounce

  18. #18
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [RESOLVED] Writing (advanced?) functions?

    For the sake of argument I shall assume the first 'C' is silent.

  19. #19

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: [RESOLVED] Writing (advanced?) functions?

    Add a K after the C when speaking it...syn-tack-tick-ah-lee
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  20. #20
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: [RESOLVED] Writing (advanced?) functions?

    I know how to pronounce it!


  21. #21
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: [RESOLVED] Writing (advanced?) functions?

    I don't know why one would really like to do things like this, but...

    VB Code:
    1. Option Explicit
    2.  
    3. Private Enum LETTERS
    4.     [UC A to Z] = 0
    5.     [LC a to z] = 1
    6. End Enum
    7.  
    8. Private Function Uniq(CaseType As LETTERS) As String
    9.     Select Case CaseType
    10.         Case [UC A to Z]
    11.             Uniq = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    12.         Case [LC a to z]
    13.             Uniq = "abcdefghijklmnopqrstuvwxyz"
    14.     End Select
    15. End Function
    16. Private Sub Form_Load()
    17.     Debug.Print Uniq([UC A to Z])
    18. End Sub

    Spooky.


    Edit!
    And if someone wants to complain about performance, then just make it an array:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Enum LETTERS
    4.     [UC A to Z] = 0
    5.     [LC a to z] = 1
    6. End Enum
    7.  
    8. Private Uniq(1) As String
    9.  
    10. Private Sub InitUniq()
    11.     Uniq([UC A to Z]) = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    12.     Uniq([LC a to z]) = "abcdefghijklmnopqrstuvwxyz"
    13. End Sub
    14. Private Sub Form_Load()
    15.     InitUniq
    16.     Debug.Print Uniq([UC A to Z])
    17. End Sub

    And it works a lot faster.
    Last edited by Merri; Jun 9th, 2006 at 09:31 AM.

  22. #22

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: [RESOLVED] Writing (advanced?) functions?

    Not quite what I had in mind (wanted to be able to use A-F, L-Z, etc) but I think I can work with that maybe :-)
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  23. #23
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: [RESOLVED] Writing (advanced?) functions?

    You'd just have a biiiiig enumeration in that case

    Anyways, what you're generally asking for is kind of a request for a new feature in VB6 language. And I don't see a big advantage in not having the quotes around a string. I'd rather just pass character codes instead of passing strings or some special variables, because handling them is much faster.

    vbKeyA for A, vbKeyB for B...

  24. #24
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: [RESOLVED] Writing (advanced?) functions?

    Here is something to think about:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Function Uniq(StartCode As KeyCodeConstants, EndCode As KeyCodeConstants) As String
    4.     Dim lngStep As Long, lngSize As Long, kccCurrent As Byte
    5.     Dim barTemp() As Byte, lngA As Long
    6.     If StartCode > EndCode Then
    7.         lngStep = -1
    8.         lngSize = StartCode - EndCode
    9.     Else
    10.         lngStep = 1
    11.         lngSize = EndCode - StartCode
    12.     End If
    13.     ReDim barTemp(lngSize + lngSize + 1)
    14.     kccCurrent = StartCode
    15.     For lngA = 0 To UBound(barTemp) - 2 Step 2
    16.         barTemp(lngA) = kccCurrent
    17.         kccCurrent = kccCurrent + lngStep
    18.     Next lngA
    19.     barTemp(lngA) = kccCurrent
    20.     Uniq = CStr(barTemp)
    21. End Function
    22. Private Sub Form_Load()
    23.     Debug.Print Uniq(vbKeyA, vbKeyD)
    24. End Sub

  25. #25

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: [RESOLVED] Writing (advanced?) functions?

    Maybe it'll be nothing, maybe it'll be useful, I dunno. You might remember me mentioning that "pet project" I am planning. Currently I am thinking that it will be a graphical OS (in the style of Windows 3.11) with lots of new built in functions (basically just DLLs written specifically for it) that programmers for the OS could use :-)

    The plan will be to make these functions freely available also, if I even bother to do it...I am sure I'll have a go...it's just a "bit of fun" to see what I can achieve with people's help and my own skills :-)
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

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