|
-
Jun 9th, 2006, 06:07 AM
#1
Thread Starter
PowerPoster
[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.
-
Jun 9th, 2006, 07:20 AM
#2
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...
-
Jun 9th, 2006, 07:46 AM
#3
Thread Starter
PowerPoster
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.
-
Jun 9th, 2006, 07:53 AM
#4
Re: Writing (advanced?) functions?
 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
-
Jun 9th, 2006, 07:53 AM
#5
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:
Public Const az = "[a-z]"
or if u use the enum u can pick it from a list...
VB Code:
Public Enum strPass
UpperA_Z = "[A-Z]"
Lowera_z = "[a-z]"
End Enum
Public Sub Test(passedin As strPass)
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 9th, 2006, 07:57 AM
#6
Thread Starter
PowerPoster
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.
-
Jun 9th, 2006, 08:14 AM
#7
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"
-
Jun 9th, 2006, 08:22 AM
#8
Re: Writing (advanced?) functions?
you can't do an Enum like that Static, it's an ENUMeration, not an ESTRINGeration
-
Jun 9th, 2006, 08:26 AM
#9
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"
-
Jun 9th, 2006, 08:34 AM
#10
Re: Writing (advanced?) functions?
 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...
-
Jun 9th, 2006, 08:54 AM
#11
Lively Member
Re: Writing (advanced?) functions?
 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:
Option Explicit
Dim StringsArr As Variant
Public Enum strPass
UpperA_Z = 1
Lowera_z = 0
End Enum
Public Sub Test(passedin As strPass)
Select Case StringsArr(passedin)
Case "[a-z]"
'..
Case "[A-Z]" ''CIRCULAR coding, convert to number, then
''conert to string again :\ useless
'..
End Select
End Sub
Private Sub Form_Load()
StringsArr = Array("[a-z]", "[A-Z]")
Test UpperA_Z
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è
-
Jun 9th, 2006, 09:03 AM
#12
Thread Starter
PowerPoster
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.
-
Jun 9th, 2006, 09:06 AM
#13
Re: Writing (advanced?) functions?
No, it's syntatically impossible.
-
Jun 9th, 2006, 09:07 AM
#14
Re: Writing (advanced?) functions?
don't you mean 'syntactically' - what a ridiculous word
-
Jun 9th, 2006, 09:12 AM
#15
Re: Writing (advanced?) functions?
Leave me alone, I'm not the forum spellchecker any more
-
Jun 9th, 2006, 09:16 AM
#16
Thread Starter
PowerPoster
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.
-
Jun 9th, 2006, 09:17 AM
#17
Re: [RESOLVED] Writing (advanced?) functions?
i just like how hard syntactically is to pronounce
-
Jun 9th, 2006, 09:20 AM
#18
Re: [RESOLVED] Writing (advanced?) functions?
For the sake of argument I shall assume the first 'C' is silent.
-
Jun 9th, 2006, 09:22 AM
#19
Thread Starter
PowerPoster
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.
-
Jun 9th, 2006, 09:25 AM
#20
Re: [RESOLVED] Writing (advanced?) functions?
I know how to pronounce it! 
-
Jun 9th, 2006, 09:26 AM
#21
Re: [RESOLVED] Writing (advanced?) functions?
I don't know why one would really like to do things like this, but...
VB Code:
Option Explicit
Private Enum LETTERS
[UC A to Z] = 0
[LC a to z] = 1
End Enum
Private Function Uniq(CaseType As LETTERS) As String
Select Case CaseType
Case [UC A to Z]
Uniq = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Case [LC a to z]
Uniq = "abcdefghijklmnopqrstuvwxyz"
End Select
End Function
Private Sub Form_Load()
Debug.Print Uniq([UC A to Z])
End Sub
Spooky.
Edit!
And if someone wants to complain about performance, then just make it an array:
VB Code:
Option Explicit
Private Enum LETTERS
[UC A to Z] = 0
[LC a to z] = 1
End Enum
Private Uniq(1) As String
Private Sub InitUniq()
Uniq([UC A to Z]) = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Uniq([LC a to z]) = "abcdefghijklmnopqrstuvwxyz"
End Sub
Private Sub Form_Load()
InitUniq
Debug.Print Uniq([UC A to Z])
End Sub
And it works a lot faster.
Last edited by Merri; Jun 9th, 2006 at 09:31 AM.
-
Jun 9th, 2006, 09:32 AM
#22
Thread Starter
PowerPoster
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.
-
Jun 9th, 2006, 09:38 AM
#23
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...
-
Jun 9th, 2006, 09:47 AM
#24
Re: [RESOLVED] Writing (advanced?) functions?
Here is something to think about:
VB Code:
Option Explicit
Private Function Uniq(StartCode As KeyCodeConstants, EndCode As KeyCodeConstants) As String
Dim lngStep As Long, lngSize As Long, kccCurrent As Byte
Dim barTemp() As Byte, lngA As Long
If StartCode > EndCode Then
lngStep = -1
lngSize = StartCode - EndCode
Else
lngStep = 1
lngSize = EndCode - StartCode
End If
ReDim barTemp(lngSize + lngSize + 1)
kccCurrent = StartCode
For lngA = 0 To UBound(barTemp) - 2 Step 2
barTemp(lngA) = kccCurrent
kccCurrent = kccCurrent + lngStep
Next lngA
barTemp(lngA) = kccCurrent
Uniq = CStr(barTemp)
End Function
Private Sub Form_Load()
Debug.Print Uniq(vbKeyA, vbKeyD)
End Sub
-
Jun 9th, 2006, 09:48 AM
#25
Thread Starter
PowerPoster
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|