|
-
Jul 15th, 2000, 09:36 AM
#1
Thread Starter
Addicted Member
Hi all,
Code:
Lyla = "Good morning Guys/Gals"
Guys = "Good morning Lyla"
Which = Right(Guys, 4) ' ==> "Lyla"
MsgBox which
How can I convert Which from "Lyla" To Lyla Without the " "
Thanx.
-
Jul 15th, 2000, 09:45 AM
#2
You mean get rid of the extra spaces? Use the Trim$ function.
Code:
MyString = Trim$(which)
-
Jul 15th, 2000, 09:50 AM
#3
Thread Starter
Addicted Member
Sorry Megatron.
I meant How can I convert Which from "Lyla" To Lyla Without the "" Quotes So I can Call the Lyla Var.
Thanx.
-
Jul 15th, 2000, 10:05 AM
#4
Code:
Public Function replacestring(strstring As String, strwhat As String, strwith As String) As String
Dim lngpos As Long
Do While InStr(1&, strstring$, strwhat$)
DoEvents
Let lngpos& = InStr(1&, strstring$, strwhat$)
Let strstring$ = Left$(strstring$, (lngpos& - 1&)) & Right$(strstring$, Len(strstring$) - (lngpos& + Len(strwhat$) - 1&))
Loop
Let replacestring$ = strstring$
End Function
Public Function trimchar(strtext As String, strchar As String) As String
trimchar$ = replacestring(strtext$, strchar$, "")
End Function
Lyla2 = trimchar("" & Which & "", "" & Chr$(34) & "")
-
Jul 15th, 2000, 10:10 AM
#5
Thread Starter
Addicted Member
Thanx Megatron & Matthew Gates.
-
Jul 15th, 2000, 10:12 AM
#6
So that is what you wanted? To remove the quotes?
-
Jul 15th, 2000, 10:17 AM
#7
Thread Starter
Addicted Member
Yes.
So when I call:
Msgbox which
It would show Good morning Guys/Gals
Thanx again.
-
Jul 15th, 2000, 10:41 AM
#8
Thread Starter
Addicted Member
Matthew Gates
It didn't work !
-
Jul 15th, 2000, 10:53 AM
#9
I don't understand..works for me.
You say you are trying to Trim(Remove) quotes. Here is an example.
Code:
Quotes = """Lyla"""
Msgbox "Before: " & Quotes
Lyla2 = trimchar("" & Quotes & "", "" & Chr$(34) & "")
Msgbox "After: " & Lyla2
Is that what you wanted? Or did I misunderstand you?
-
Jul 16th, 2000, 12:32 AM
#10
Thread Starter
Addicted Member
Dear Matthew Gates,
Run this code in a Form_load:
Code:
Lyla = "Good morning Guys/Gals"
Guys = "Good morning Lyla"
Which = Right(Guys, 4)
'Toggle a breakpoint in your code
'and chech the value of which ???
MsgBox which ' ==> "Lyla" with Quotes
I want to use the returned value of which Without
Quotes ??
Sorry for not being very clear .
Thanx again.
-
Jul 16th, 2000, 09:11 AM
#11
Thread Starter
Addicted Member
Wow! 70 people !?
Please help? 
-
Jul 16th, 2000, 06:40 PM
#12
Thread Starter
Addicted Member
I hope this simple example would clear things up 
Code:
Dim Lyla As String
Dim Guys As String
Dim which As String
Lyla = "Good morning Guys/Gals"
Guys = "Good morning Lyla"
which = Right(Guys, 4) ' ==> "Lyla"
Open file2 For Binary As fnum
Put #fnum, , which
Close fnum
I'm very sorry for being such a pain 
-
Jul 16th, 2000, 07:01 PM
#13
Sorry, but without an explanation of what you are trying to do, I can't help.
-
Jul 16th, 2000, 08:15 PM
#14
Lyla,
maybe a collection of strings comes close to what you are trying to do, although i don't understand why:
'**********************************************************
Private mcolString As New Collection
Private Sub Form_Load()
With mcolString
.Add "Good morning Guys/Gals", "Lyla"
.Add "Good morning Lyla", "Guys"
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set mcolString = Nothing
End Sub
Private Sub Command1_Click()
With mcolString
.Add Right(.Item("Guys"), 4), "which"
MsgBox .Item(.Item("which"))
End With
End Sub
'**********************************************************
best regards
Sascha
-
Jul 16th, 2000, 08:43 PM
#15
Hyperactive Member
Sascha
Good Answer 
Lyla
I can understand what you are trying to do but you are mixing things which are dynamic (ie the contents of strings) with something that is static (ie the names of variables).
When you do this it is very easy to become not only confused but also very lost... hence the reason people didn't understant what you were attempting to do.
I would say the best solution is that which Sascha gave you althought I would include error checking just in case the string you are searching for does not exist in the collection.
Using this method you can have several key "phrases" that you can then assign strings to be replaced with and could do it on the fly.
The use of the word Lyla as a variable simply says that it is a pointer to a string and it could be called Beetlejuice as far as anyone is concerned. When you compile your application the word Lyla is completely removed as it only has meaning when you are coding it.
That is why we can basically use anything for a variable name... because all of those names are collected up and thrown out the window when it is compiled to be replaced with pointers that still do the job.... the name only has meaning to the programmer and that is why you really shouldn't and wouldn't use it inside your code as you were trying to do.
-
Jul 17th, 2000, 10:07 AM
#16
Thread Starter
Addicted Member
-
Jul 17th, 2000, 10:25 AM
#17
_______
<?>
my guess...
Lyla is printing the string to a file
and then reading the file for display, but
when she does she is getting the file
delimiters imposed on the string.
this is not your answer but it will show you
one way to get rid of the delimiter...
Print statement instead of write..Private Sub Command1_Click()
Lyla = "Good morning Guys/Gals"
Guys = "Good morning Lyla"
which = Right(Guys, 4)
'Toggle a breakpoint in your code
'and chech the value of which ???
MsgBox which ' ==> "Lyla" with Quotes
Dim file2
file2 = "c:\a\a.txt"
Dim fnum As Integer
fnum = FreeFile
Open file2 For Output As fnum
Print #fnum, which
Close fnum
Open file2 For Input As fnum
Input #fnum, which
MsgBox which
Close
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
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
|