Ok, i know this but i cant think of it at the moment. I have a bunch of IF statements and i want it to perform like three things after each IF statement. My prob is i cant remember how to get it to do more that one.
Printable View
Ok, i know this but i cant think of it at the moment. I have a bunch of IF statements and i want it to perform like three things after each IF statement. My prob is i cant remember how to get it to do more that one.
Code:If Text1.Text = "Hello" Then
Msgbox "1"
Msgbox "2"
Msgbox "3"
Endif
:)
this might help:
is this what you mean?Code:
if something.something then
something
something
something
end if
if booleanflag then a=b:b=c:c=d
Code:dim x,y,z
x = 0
y = 1
z = 2
if x = o then
msgbox "help"
if y = 1 then
msgbox "me"
if z = 2 then
msgbox "out"
end if
end if
end if
'or all in one
if x = o and y =1 and z = 2 then msgbox "help me out"
Ok, some of the if statments work, but the others dont even seem to be read.
Post your current code. There might be a fault in the statement themselves.
By saying that some work and some do not do you mean that some IF statements are not even reached but that they should be?
Are these nested If's or are they separate if's?
The answers given cover all of these possibilities, so I think you should be able to find the problem now.
Remember that all IF statements MUST have a THEN on the same line. The statements you want to have executed may be on the next line in which case you MUST eventually have and End If.
If the statement you want to execute is on the same line as the THEN clause, then you may not have an End If.
Additonally you can have an ELSE statement.
If by some chance you were trying to think of the Select Case ... End Select statement, then hopefully my mentioning it will remind you...
This is useful for eliminating nested If's that make reading code hard sometimes.
Hope it helps
Paul Lewis
paste your code so we can see what you
are trying to accomplish..
PaulLewis you said "By saying that some work and some do not do you mean that some IF statements are not even reached but that they should be? ". Thats exactly what i mean. Well, here is the code...
It reaches up to like the 33rd or 34th IF statment, but wont go farther then that.Code:Public Sub Change(CText As String)
Dim i As Integer
Dim stri As String
For i = 1 To Len(CText)
stri = Mid(CText, i, 1)
If stri Like Chr(0) Then stri = Replace(stri, Chr(0), "CHR(0) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(1) Then stri = Replace(stri, Chr(1), "CHR(1) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(2) Then stri = Replace(stri, Chr(2), "CHR(2) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(3) Then stri = Replace(stri, Chr(3), "CHR(3) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(4) Then stri = Replace(stri, Chr(4), "CHR(4) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(5) Then stri = Replace(stri, Chr(5), "CHR(5) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(6) Then stri = Replace(stri, Chr(6), "CHR(6) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(7) Then stri = Replace(stri, Chr(7), "CHR(7) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(8) Then stri = Replace(stri, Chr(8), "CHR(8) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(9) Then stri = Replace(stri, Chr(9), "CHR(9) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(10) Then stri = Replace(stri, Chr(10), "CHR(10) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(11) Then stri = Replace(stri, Chr(11), "CHR(11) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(12) Then stri = Replace(stri, Chr(12), "CHR(12) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(13) Then stri = Replace(stri, Chr(13), "CHR(13) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(14) Then stri = Replace(stri, Chr(14), "CHR(14) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(15) Then stri = Replace(stri, Chr(15), "CHR(15) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(16) Then stri = Replace(stri, Chr(16), "CHR(16) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(17) Then stri = Replace(stri, Chr(17), "CHR(17) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(18) Then stri = Replace(stri, Chr(18), "CHR(18) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(19) Then stri = Replace(stri, Chr(19), "CHR(19) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(20) Then stri = Replace(stri, Chr(20), "CHR(20) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(21) Then stri = Replace(stri, Chr(21), "CHR(21) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(22) Then stri = Replace(stri, Chr(22), "CHR(22) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(23) Then stri = Replace(stri, Chr(23), "CHR(23) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(24) Then stri = Replace(stri, Chr(24), "CHR(24) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(25) Then stri = Replace(stri, Chr(25), "CHR(25) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(26) Then stri = Replace(stri, Chr(26), "CHR(26) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(27) Then stri = Replace(stri, Chr(27), "CHR(27) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(28) Then stri = Replace(stri, Chr(28), "CHR(28) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(29) Then stri = Replace(stri, Chr(29), "CHR(29) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(30) Then stri = Replace(stri, Chr(30), "CHR(30) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(31) Then stri = Replace(stri, Chr(31), "CHR(31) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(32) Then stri = Replace(stri, Chr(32), "CHR(32) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(33) Then stri = Replace(stri, Chr(33), "CHR(33) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(34) Then stri = Replace(stri, Chr(34), "CHR(34) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(35) Then stri = Replace(stri, Chr(35), "CHR(35) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(36) Then stri = Replace(stri, Chr(36), "CHR(36) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(37) Then stri = Replace(stri, Chr(37), "CHR(37) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(38) Then stri = Replace(stri, Chr(38), "CHR(38) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(39) Then stri = Replace(stri, Chr(39), "CHR(39) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(40) Then stri = Replace(stri, Chr(40), "CHR(40) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(41) Then stri = Replace(stri, Chr(41), "CHR(41) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(42) Then stri = Replace(stri, Chr(42), "CHR(42) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(43) Then stri = Replace(stri, Chr(43), "CHR(43) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(44) Then stri = Replace(stri, Chr(44), "CHR(44) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(45) Then stri = Replace(stri, Chr(45), "CHR(45) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(46) Then stri = Replace(stri, Chr(46), "CHR(46) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(47) Then stri = Replace(stri, Chr(47), "CHR(47) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(48) Then stri = Replace(stri, Chr(48), "CHR(48) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(49) Then stri = Replace(stri, Chr(49), "CHR(49) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(50) Then stri = Replace(stri, Chr(50), "CHR(50) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(51) Then stri = Replace(stri, Chr(51), "CHR(51) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(52) Then stri = Replace(stri, Chr(52), "CHR(52) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(53) Then stri = Replace(stri, Chr(53), "CHR(53) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(54) Then stri = Replace(stri, Chr(54), "CHR(54) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(55) Then stri = Replace(stri, Chr(55), "CHR(55) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(56) Then stri = Replace(stri, Chr(56), "CHR(56) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(57) Then stri = Replace(stri, Chr(57), "CHR(57) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(58) Then stri = Replace(stri, Chr(58), "CHR(58) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(59) Then stri = Replace(stri, Chr(59), "CHR(59) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(60) Then stri = Replace(stri, Chr(60), "CHR(60) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(61) Then stri = Replace(stri, Chr(61), "CHR(61) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(62) Then stri = Replace(stri, Chr(62), "CHR(62) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(63) Then stri = Replace(stri, Chr(63), "CHR(63) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(64) Then stri = Replace(stri, Chr(64), "CHR(64) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(65) Then stri = Replace(stri, Chr(65), "CHR(65) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(66) Then stri = Replace(stri, Chr(66), "CHR(66) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(67) Then stri = Replace(stri, Chr(67), "CHR(67) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(68) Then stri = Replace(stri, Chr(68), "CHR(68) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(69) Then stri = Replace(stri, Chr(69), "CHR(69) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(70) Then stri = Replace(stri, Chr(70), "CHR(70) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(71) Then stri = Replace(stri, Chr(71), "CHR(71) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(72) Then stri = Replace(stri, Chr(72), "CHR(72) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(73) Then stri = Replace(stri, Chr(73), "CHR(73) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(74) Then stri = Replace(stri, Chr(74), "CHR(74) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(75) Then stri = Replace(stri, Chr(75), "CHR(75) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(76) Then stri = Replace(stri, Chr(76), "CHR(76) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(77) Then stri = Replace(stri, Chr(77), "CHR(77) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(78) Then stri = Replace(stri, Chr(78), "CHR(78) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(79) Then stri = Replace(stri, Chr(79), "CHR(79) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
1:
Next i
End Sub
I hope you guys can see something wrong.
But I can see why you asked for help.
Only I don't understand why you said "I can't believe I am asking this..". The code looks to me like you are a beginner and as such you shouldn't worry about what you know/don't know...
Everyone learns new techniques all the time. The main reason I have started contributing here is because it helps teach me stuff every time I reply :)
I will get back to you soon with a solution (as no doubt other helpful people)
:)
Cheers
Paul
How about changing the code to something like this:
I think it does what your code does, but it's a little bit shorter (I didn't test it or anything so it might not work)Code:Public Sub Change(CText As String)
Dim I As Integer
Dim J As Integer
Dim stri As String
For I = 1 To Len(CText)
stri = Mid(CText, I, 1)
For J = 1 To 79
If stri Like Chr(J) Then
stri = Replace(stri, Chr(J), "CHR(" & J & ")", , , vbTextCompare)
rtfAfter.Text = rtfAfter.Text + stri
GoTo 1
End If
Next J
1:
Next I
End Sub
[Edited by QWERTY on 07-11-2000 at 08:14 PM]
QWERTY beat me to a reply for you however I will still post this in case it helps
I think the key concepts for you to remember here are:
IF..THEN..ENDIF syntax.
ASC(string) returns the ascii value of the first character of the string - this would probably have helped you alot!!
String addition (concatenation): You can join strings with the & operator.
Functions: These are good because they return a value to you. This ChangeText function is generic which means you can use it in any code in any project, even if there is no control called "rtfAfter".
Most important: Whenever you have more than a couple of lines that are exactly the same except for a constant or two, there will always be another way of coding that is shorter, faster and undoubtedly better ;)
Hope we've all helped :)Code:
Private Sub Command1_Click()
Dim myText As String
myText = Chr(3) & "here " & Chr(23)
rtfAfter.Text = ChangeText(myText)
End Sub
Public Function ChangeText(CText As String) As String
Dim i, ascVal As Integer
Dim stri, newStr As String
For i = 1 To Len(CText)
stri = Mid(CText, i, 1)
ascVal = Asc(stri)
If ascVal < 80 Then
stri = "CHR(" & ascVal & ") "
End If
newStr = newStr + stri
Next
ChangeText = newStr
End Function
Paul Lewis
I seem to have replaced your functionality with what I thought you were trying to do.
However, my code does not do what yours did. Your code doesn't reach certain if statements because of the goto statement. Your code allows for multiple matches of the same character due to the way LIKE works.
I have never used LIKE in this way so I was unaware of this behaviour. Did you intend for this to happen?
For example, did you know that character 42 is the "*" symbol?
If you ask VB whether any text is "like *", you will be told YES!
Is this want you want? If not, use my code. If it is what you want, use QWERTY's code.
Regards
Paul Lewis
Thank you all for helping, but the most thanks goes to PaulLewis. You told me about the asc() function and now my code looks like this...
It works perfectly and is a whole lot faster.Code:Public Sub Change(CText As String)
Dim i As Integer
Dim stri As String
For i = 1 To Len(CText)
stri = Mid(CText, i, 1)
rtfAfter.Text = rtfAfter.Text & "CHR(" & Asc(stri) & ") "
Next i
End Sub
Thank you...
No offense meant but the original list of Ifs is not good
coding.
Replace any huge list of Ifs with the Select Case construct
Just a thought for your future coding benefit:):):):)Code:Select Case stri
Case Chr(0):Do whatever
Case Chr(1):Do whatever
End Select
I did, i replaced that whole list of ifs with the code i wrote above.
We took on a junior programmer from the states this week, who was totally unaware of the Select Case construct. What do they teach people in the US:):):):):):)
I think they teach them that they won Vietnam
Yeah the U.S.A was invented to give Aussies something to laugh about, mind you Australia was invented to give Kiwis a good chuckle......
Jethro, is that my cue to chuckle?
Actually, I'm a big sports fan so I don't have alot to laugh at the Aussies for at present :(
Oh well...
I don't Care about sport So I get to laugh at England with the Rest of the World
Are you making fun of me cuz i live in america?
Im really Irish.
love me.
please!!!!!!!!
I NEED LOVE!!!!!!!!!!!!!!
Paul
Are you a kiwi mate???????
Monkey Boy
Of course we are....the rest of the world laughs at seppos, though if your irish it kind of takes the fun out of it.
Sam
You old bat you:):):)What goes around comes around, at least your lads did it against the South Africians in the Rugby
OK
I use alot of elseif's and For loops. Usually this gets me through most things. I don't like using select case a whole bunch when I'm checking for cases like case 1 , case 1 + 2, case 1 + 2 + 3.
Aussies make good beer and the English make good ale, and I like to drink both. Then I use my "in-house" plumbing afterward and relize how good it is to live in America where I don't have to go outback or down the hall to relieve myself.
Actually They Istalled a Toilet in the Village next to ours 3 Weeks ago, So now it's only a 10 minute walk to the Crapper. It's God Every Modern Convinience as well, Including a nice Fresh supply of leaves next to it.
Well I can't believe it's not butter!
Yes Jethro I am a Kiwi :)
I can see now why so many people have hundreds of messages in the message count ;) And isn't it funny how one little (slightly derogative) comment from Jethro can change a thread rather quickly :)
I guess ChimpFace got more that he bargained for in asking the question huh?
Cheers
Paul Lewis
The Kiwi (or one of them anyway)
Actually you got the language wrong:(
If l wanted to take a piss in the outback, l would have
to get into my car drive for twenty or so hours to get there.
In Oz the Outback means the bush...you know the great outdoors, the wilderness, rural areas...
As in
"What are you doing this weekend mate?"
"Going to chuck the old sheila in the ute and go outback
to shot some roos Bruce. Might even down a slab or two. Yeah, you wouldn't be dead for quids.":D
Hehehehe AUSSIES RULE!!!!!!
Just wait for the swimming at the OLYMPICS....
(oh and by the way 'slab' in australia is a carton of beer - 24 beers)
hehehe and boy thats really a way to get totally wasted...
Originally from Hastings myself, (still a Hawkeye Guy). Have been in oz for approx 20 years, my wife is an aussie, and my dad is an aussie. I support all things Australian...unless....it is against New Zealand.
Thie saturday going out to Stadium Australia to see the All Blacks pound the Wallabies into the dust. Got to be a sight, 100,000 Aussies crying into their beer.
Cullen to score the first try from inside own half.
at the number of Aussies and Kiwis posting by the post dates and times.
Unless there are alot of Northern Hemisphere night owls!
As yo know I'm new here and while I have time up my sleeve I'll answer as much as I can (even if I don't know the answer - heehe) since you never know when a mate or two online could come in handy.
:)
whoa this used to be a VB forum.... now its a pub house happy hour!!! :)
We should really get John to move this over to Chit Chat now, as the originator of the post has his answer, and we are probably starting to distract people from the real reason for this forum.
WOW! This looks extreemly beautiful!Quote:
Code:Public Sub Change(CText As String)
Dim i As Integer
Dim stri As String
For i = 1 To Len(CText)
stri = Mid(CText, i, 1)
If stri Like Chr(0) Then stri = Replace(stri, Chr(0), "CHR(0) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(1) Then stri = Replace(stri, Chr(1), "CHR(1) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(2) Then stri = Replace(stri, Chr(2), "CHR(2) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(3) Then stri = Replace(stri, Chr(3), "CHR(3) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(4) Then stri = Replace(stri, Chr(4), "CHR(4) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(5) Then stri = Replace(stri, Chr(5), "CHR(5) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(6) Then stri = Replace(stri, Chr(6), "CHR(6) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(7) Then stri = Replace(stri, Chr(7), "CHR(7) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(8) Then stri = Replace(stri, Chr(8), "CHR(8) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(9) Then stri = Replace(stri, Chr(9), "CHR(9) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(10) Then stri = Replace(stri, Chr(10), "CHR(10) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(11) Then stri = Replace(stri, Chr(11), "CHR(11) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(12) Then stri = Replace(stri, Chr(12), "CHR(12) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(13) Then stri = Replace(stri, Chr(13), "CHR(13) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(14) Then stri = Replace(stri, Chr(14), "CHR(14) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(15) Then stri = Replace(stri, Chr(15), "CHR(15) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(16) Then stri = Replace(stri, Chr(16), "CHR(16) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(17) Then stri = Replace(stri, Chr(17), "CHR(17) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(18) Then stri = Replace(stri, Chr(18), "CHR(18) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(19) Then stri = Replace(stri, Chr(19), "CHR(19) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(20) Then stri = Replace(stri, Chr(20), "CHR(20) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(21) Then stri = Replace(stri, Chr(21), "CHR(21) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(22) Then stri = Replace(stri, Chr(22), "CHR(22) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(23) Then stri = Replace(stri, Chr(23), "CHR(23) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(24) Then stri = Replace(stri, Chr(24), "CHR(24) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(25) Then stri = Replace(stri, Chr(25), "CHR(25) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(26) Then stri = Replace(stri, Chr(26), "CHR(26) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(27) Then stri = Replace(stri, Chr(27), "CHR(27) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(28) Then stri = Replace(stri, Chr(28), "CHR(28) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(29) Then stri = Replace(stri, Chr(29), "CHR(29) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(30) Then stri = Replace(stri, Chr(30), "CHR(30) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(31) Then stri = Replace(stri, Chr(31), "CHR(31) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(32) Then stri = Replace(stri, Chr(32), "CHR(32) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(33) Then stri = Replace(stri, Chr(33), "CHR(33) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(34) Then stri = Replace(stri, Chr(34), "CHR(34) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(35) Then stri = Replace(stri, Chr(35), "CHR(35) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(36) Then stri = Replace(stri, Chr(36), "CHR(36) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(37) Then stri = Replace(stri, Chr(37), "CHR(37) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(38) Then stri = Replace(stri, Chr(38), "CHR(38) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(39) Then stri = Replace(stri, Chr(39), "CHR(39) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(40) Then stri = Replace(stri, Chr(40), "CHR(40) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(41) Then stri = Replace(stri, Chr(41), "CHR(41) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(42) Then stri = Replace(stri, Chr(42), "CHR(42) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(43) Then stri = Replace(stri, Chr(43), "CHR(43) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(44) Then stri = Replace(stri, Chr(44), "CHR(44) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(45) Then stri = Replace(stri, Chr(45), "CHR(45) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(46) Then stri = Replace(stri, Chr(46), "CHR(46) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(47) Then stri = Replace(stri, Chr(47), "CHR(47) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(48) Then stri = Replace(stri, Chr(48), "CHR(48) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(49) Then stri = Replace(stri, Chr(49), "CHR(49) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(50) Then stri = Replace(stri, Chr(50), "CHR(50) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(51) Then stri = Replace(stri, Chr(51), "CHR(51) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(52) Then stri = Replace(stri, Chr(52), "CHR(52) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(53) Then stri = Replace(stri, Chr(53), "CHR(53) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(54) Then stri = Replace(stri, Chr(54), "CHR(54) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(55) Then stri = Replace(stri, Chr(55), "CHR(55) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(56) Then stri = Replace(stri, Chr(56), "CHR(56) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(57) Then stri = Replace(stri, Chr(57), "CHR(57) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(58) Then stri = Replace(stri, Chr(58), "CHR(58) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(59) Then stri = Replace(stri, Chr(59), "CHR(59) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(60) Then stri = Replace(stri, Chr(60), "CHR(60) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(61) Then stri = Replace(stri, Chr(61), "CHR(61) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(62) Then stri = Replace(stri, Chr(62), "CHR(62) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(63) Then stri = Replace(stri, Chr(63), "CHR(63) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(64) Then stri = Replace(stri, Chr(64), "CHR(64) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(65) Then stri = Replace(stri, Chr(65), "CHR(65) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(66) Then stri = Replace(stri, Chr(66), "CHR(66) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(67) Then stri = Replace(stri, Chr(67), "CHR(67) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(68) Then stri = Replace(stri, Chr(68), "CHR(68) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(69) Then stri = Replace(stri, Chr(69), "CHR(69) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(70) Then stri = Replace(stri, Chr(70), "CHR(70) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(71) Then stri = Replace(stri, Chr(71), "CHR(71) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(72) Then stri = Replace(stri, Chr(72), "CHR(72) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(73) Then stri = Replace(stri, Chr(73), "CHR(73) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(74) Then stri = Replace(stri, Chr(74), "CHR(74) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(75) Then stri = Replace(stri, Chr(75), "CHR(75) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(76) Then stri = Replace(stri, Chr(76), "CHR(76) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(77) Then stri = Replace(stri, Chr(77), "CHR(77) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(78) Then stri = Replace(stri, Chr(78), "CHR(78) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
If stri Like Chr(79) Then stri = Replace(stri, Chr(79), "CHR(79) ", , , vbTextCompare): rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
1:
Next i
End Sub
Well I know you guys discussed this out but this, this is just something that beats all records!
stri = Mid(CText, i, 1) means that stri is 1 character!!
If stri Like Chr(0) Then you use the LIKE operator to compare the strings instead of =!!!!
stri = Replace(stri, Chr(0), "CHR(0) ", , , vbTextCompare)
Replacing all chr(0)'s in the string successfully!!! Nice job! THis is great code!
rtfAfter.Text = rtfAfter.Text + stri: GoTo 1
And then you add the string back again, and then GOTO 1!!!!!!
Well if you still want a better code, this beats em' all cause it's ten times faster!
Code:Public Sub Change(CText As String)
Dim a() As Byte, I As Integer
a = StrConv(CText, vbFromUnicode)
For I = 0 To UBound(a)
rtfAfter = rtfAfter & "CHR(" & a(I) & ") "
Next I
End Sub
Now i feel really bad...
and stupid...
and humiliated...
But im feeling better....
I fell better because one day I will rule the world...
the United States of America...
and YOU!!!
We are all learning on here otherwise we are wasting our time.
I used to write code like your sample too. You have to remember tha tyour code is still infinitely better than what 99 % of the rest of humanity could accomplish.
You were in the right ballpark to coin a phrase... and you just needed a bit of coaching and maybe one or two net practices :)
Keep on asking questions because in the short time I have been here, I have always found people to answer the easy as well as the curly questions :)
Cheers
Paul Lewis
monkey boy
We all feel stupid from time to time with coding, there is always something new to learn, if there wasn't then the language would be really boring and l for one would move on to something else. Like l am doing with Pick.
joey o
Got to disagree with you dude. Select Case is superior to Ifs for multiple cases, e.g
Should be replaced with,Code:
If A = 1 Then
If A = 2 Then
.
.
.
If A = 300 Then
The Select case is more efficient in this example, cause not every line is going to be evaluated...Code:Select Case A
Case 1
Case 2
.
.
.
Case 300
End Select
Get life Kedaman, Register Mar 2000, 1968 Posts.
What do you mean, get a life??? Kedaman has made 1,968 posts since March of this year? So what's the big deal about that?!? Let's do the math. Let's say it was March 1st when the first post went up, that would be approximately 130 days ago . . .
That's only 15 posts a day! Hey, they add up, man! I mean, reading enough posts to be inspired to put up 15 replies a day, that still leaves a lot of time in the day. That would give a person enough time to order pizza (twice), move your bowels, clip your fingernails and still have time to get in 15 hours of writing code before you pass out in a fitfull sleep of binary dreams.
It's not like guru's are helpful or anything is it ? Anyway, who is the top member for average posts a day ? Post your averages here and see who's top. Mine's patheticly low < 2.
It's not very helpfull when he mocks someone's code. This forum is about asking questions and getting help, not to show that you can program better than the other person.
I've never known him to Mock code before, but He Shouldn't be Doing it. Bad Kedman. Other than that he's normally quite good I think he's thee fastest person to rise to Guru Status, but I may be wrong.
God bless the hyperactives and the gurus! I continue to be amazed at how generous these people are with their time. If Kedaman felt compelled to post up that code a second time just to admire how bee-utiful it looks, so be it. If you come here seeking knowledge, it helps to not take yourself too seriously.
I try to keep my average down to one post a day because at this juncture, every one of my posts just happens to be a question, usually with containing the text "how do I . . . " I figure that posting any more than one or two of these on a daily basis would be pushing it.
Awww, i didnt take Kedamans post seriously. Actually i was laughing pretty hard when reading. Just as long as he didnt mean anything by it, im ok with it.
As long as you were laughing then I withdraw my mental picture of the Evil Kedaman...cackling and howling with laughter at our attempts to write keda-code...
As we know, there is only one kdeaman and therefor only one source of keda-code in this universe :)
Thats all I'm going to write in this thread cos we're a little off topic, and like the man said "move it to chit chat"
Cheers
Paul Lewis
Always found him helpful with good code tips. However, everyone has their own style, as to his average post count per day....who cares....l noticed yesterday that people are logged here all day long, Gen-X do you actually do anything else:):):)....oh my god, that must mean l was logged on for hours.........
Sorry, i'm so sorry about that, if you still care. Sometimes i just post stupid things and normally i would delete them but this time i haven't been here for three days and that means everyone have already seen how stupid i am. Damn!Quote:
Now i feel really bad...
and stupid...
and humiliated...
So Jethro, there isn't a Evil Kedaman, it's just a myth.
But really, i liked that code, i surely have done something that looks like that in my first days with gwbasic.
For post masters, i'm not the most fanatic, look at Megatron lately. WEll i know he got here one year before me but 9/10ths of hes posts are posted after i joined
It turns out that he didn't go and jump of the top of Bill Gate's bank vault (I hear it's pretty big..) so I guess ChimpFace wasn't as sensitive as others (like me :) )
Anyhow, since it's a good topic, I'm starting my first thread in chit chat about "ancient" basic languages...(i.e. more than 2 minutes old).
Here is the link, then we can all humiliate and ridicule each other :)
http://forums.vb-world.net/showthrea...threadid=23379
Cheers
Paul Lewis
That looks like it could be a long lasting thread, as long as people see it.
I was indicating that there is no such thing as an Evil Kedaman not that there is an evil kedaman, had at one time decided to bill myself as namadek, sort of the evil antikedaman twin brother his mother never told him about...but John lost all sense of humour in this...so canned the thread. No offense intended man, was just some humour....As indicate l always find your answers helpful and too the point, (as opposed to this actually), will endeavour not to waste your valuable time in future...hehehehehehehehehehehehehehehe
Gonna over to chit chat to check out this ancient basic thread.
Jethro! You never stop to jump around me? Everywhere I'm posting, youre posting, everything I say, you comment, every day i'm here, youre here, Yeah I know that you didn't mean that, seriously, I wasn't serious at all but Ancient legend's says that there is an evil manadek; from every simple juniour member upto the most greatest Guru, there is an evil twin that jumps around you and negates you with everything, hehe, Jethro I hope you don't seriously believe in such stories
Not sure if this the best example, but I had trouble using Select Case with this type of stuff where "A" is being checked for True:
If "A" then
do this
ElseIf "A" AND "A" then
do this and that
ElseIf "A" And "A" And "A" then
do this and that and do more
End if
If "A" was true in the last Elseif it would fire in the select statement on the first true instance where there was only one true "A". No time to think, but do you see my point?
Joey O.
This thing that I just posted is useless, I am just posting this becuase I was one of the first people to post a reply and now I'm getting a email everytime someone replies, so I'm gonna uncheck the Email Notification button, again, this reply has no point
joey
Ok l see what you are trying to say, but couldn't you equal write
kedamanCode:Case "A" And "A" And "A"
Case "A" And "A"
Case "A"
It could be equally argued that you are always here when l am here, and you post around my posts. Do you notice Megatron also posts around our posts. The boy has some sort of radar for this.
Also clicking off email notification on this one:)
Yeah, we need to develope an radar jammer, an email notification blocker or somthing, I'm just about to make a prog that prevent's you from pressing the submit-reply button and then when you press it, it won't send email notifications to everyone because you can't press it, sounds good?
sounds like a very good idea to me, I can help you if you need (but I doubt that you can't do everything)
Are you and Meg still dueling with post counts?
What do you mean Jethro?!? That I would care about something as trivial as p o s t c o u n t s?!?!
Thanks Jethro, you are one real good guy but I really thought I made it clear
The postracing stopped three months ago