Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 23rd, 2004, 03:48 PM
Authorized User
 
Join Date: Sep 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to huyremy
Default String in VB6 ?

I have just make a simple app using Inet to get one string from HTML document and this is my code
Code:
Private Sub Command1_Click()
Text1.Text = "Please Wait......."
Dim a As Integer, b As Integer
Dim strURL As String, strIP As String
 strURL = Inet1.OpenURL(Text2.Text)
    a = InStr(1, strURL, "<TITLE>", vbTextCompare)
    b = InStr(1, strURL, "</TITLE>", vbTextCompare)
    strIP = Mid(strURL, a + 7, b - (a + 7))
    Text1.Text = strIP
End Sub
It's run very well . But now I have big problem .
I don't want to get string in a title tags . I want to get string on this tags
Code:
]<meta http-equiv="keywords" content=" this string a want to get " >
The problem is quoted . VB can not understand the quoted which is " .
Any body can help me ?

 
Old November 24th, 2004, 12:29 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

To specify a " in a literal string, use "".

In the Debug window, the following

?"A quote looks like ""."

will return

A quote looks like ".

If you were searching for
]<meta http-equiv="keywords" content=" this string a want to get " >

you would say

  If str = "]<meta http-equiv=""keywords"" content="" this string a want to get "" >" Then

Does that help?
 
Old November 24th, 2004, 02:47 PM
Authorized User
 
Join Date: Sep 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to huyremy
Default

Quote:
quote:Originally posted by BrianWren
 To specify a " in a literal string, use "".

In the Debug window, the following

?"A quote looks like ""."

will return

A quote looks like ".

If you were searching for
]<meta http-equiv="keywords" content=" this string a want to get " >

you would say

  If str = "]<meta http-equiv=""keywords"" content="" this string a want to get "" >" Then

Does that help?

---------------------------
That is the good idea . But i have another way to do that work .
then this is my code
Code:
Dim c as String
c = "<meta http-equiv=" + chr(34) + "keywrods" + chr(34)
Text1.text = c
I think chr(34) will help us print the double quote ( " ) in the string. any comment ?

 
Old November 24th, 2004, 04:30 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Frankly, I don't think that that is better. It makes the string much longer in the development area, and is not nearly as clear to read.

If you sometime add Chr(9) for a tab, or chr(13) for a linefeed, much more close examination of the code is necessary for following the flow.

Additionally, the + ... + is not seen as constant in length, and so VB has to make a lot of memory allocations, and do calculations to finish setting the value of c.

With the "", the actual resultant code in the EXE only has one " in the string that is stored for insertion into c, and so VB can calculate the needed memory in one operation.

But if you insist on using Chr, use Chr$(). The functions Left, Mid, Right, Chr all have a form with a trailing $. That calls a different funtion than is called without the $. Without it, a variant/String is returned, and VB has to convert it for inclusion into the literal string. The form with the $ returns a true string, and so is faster. Also, you should join strings with & rather than +.

"Hello" + Null = Null
"Hello" & Null = "Hello"





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to find a string in another string in vb6 satish_k VB How-To 3 March 30th, 2007 12:17 PM
What is the VB .NET replacement for VB6 String()? BrianWren VB.NET 2002/2003 Basics 4 November 4th, 2005 11:46 AM
What is the VB .NET replacement for VB6 String()? BrianWren VB.NET 0 September 19th, 2005 11:05 AM
String Manipulation in VB6 Jay5817 Pro VB 6 7 January 20th, 2004 01:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.