Loans | Holiday In Mexico | Loans | Mortgages | Mortgage Calculator
More Basic VB coding issues... [Archive] - PCMech Forums

PDA

View Full Version : More Basic VB coding issues...


artsapimp
06-13-2000, 04:19 PM
I have decided to try my luck in programming again (who knows how many times I've said that?). I am using VB because my coding knowledge is well below average and I understand it's the easiest to learn. I am very happy with how well I'm doing but have come across a problem.

I have a button that when clicked I want it to populate a text box (txtLink) with:
<code>< a href="link.htm" >linktext< /a ></code>.
The obvious problem is when I put:
<code>txtLink.SelText = "< a href=" </code>
it's then done with that line of code. How could I make it around this? Thanks for your help.

------------------
If you think an education is expensive...try ignorance.

[This message has been edited by artsapimp (edited 06-13-2000).]

Paul Victorey
06-13-2000, 06:33 PM
If I understand the query, you need to know how to put quotation marks within a string, that is delimited by quotation marks?

Generally, you need to use an escape character in place of the quotation. I don'tknow about VB, but in PERL, you would do:

$selectText = "&lt;a href=\"link\"&gt;link&lt;/a&gt;";

You also know the quotes in the tag are optional? &lt;a href=link&gt; will work too.

------------------
Paul M. Victorey
------------------
I am not responsible for any problems that may arise as a result of following my advice. This includes, but is not limited to, computer failure, loss of data, nuclear war, famine, boils, no clean laundry, your daughter running off with a biker gang, or armageddon. Take my advice at your own risk.

artsapimp
06-13-2000, 07:49 PM
Thank you very much. I chose to use the link without the "s but I'm sure the others work also. I have come across a few more blocks in my attempts to make this program. Please help with whatever you can, thanks.

The program is an HTML editor. It already uses the basic Notepad functions, but I wanted to add a few more to customize it.

1. Text1.text starts with the tags already there, in different lines.
< HTML >
< HEAD >
< TITLE >TITLE</ TITLE>
</ HEAD >....
you get the picture
I tried to write it but everything's on the same line, I don't know how to use a < BR > in VB.

2. I would like to have all links in a different color (red), all asp code in another color (blue), etc. How would I say everything between < % and % > is blue?

3. How do I make the program save as .html, .htm, .asp, etc.?

Thanks for all of your help.



------------------
If you think an education is expensive...try ignorance.

artsapimp
06-13-2000, 07:57 PM
Forget #3, I did that myself. Still don't know 1 or 2 though. Thanks

------------------
If you think an education is expensive...try ignorance.

Rick Hall
06-14-2000, 02:37 AM
Here is how to do it

TxtLink.SelText = "< a href=link.htm>linktext< /a >"

Or

TxtLink.text = "< a href=link.htm>linktext< /a >"


------------------
Rick

>> -- <<
The solutions to todays problems,
Are the problems of tomorrow.

RH WebWorx - Site Creators (http://www.total.net/~hallrm)

[This message has been edited by Rick Hall (edited 06-14-2000).]

[This message has been edited by Rick Hall (edited 06-14-2000).]

UncaDanno
06-14-2000, 04:00 AM
In VB, you don't need escape characters in strings. You can use them, but they're no necessary. To include a quote (or double-quote, as some call it), type it twice. VB will translate it as an embedded single occurance.

Or you can concatenate the character equivalent: str = "< a href=" & chr(34) & "link........"

chr(34) is the quote mark. 65 thru 90 is the upper-case alphabet. 97 thru 122 is the lower-case alphabet.

If you have a copy of the MSDN Library, look up "ANSI character codes chart" in the index for values you can put in chr().

artsapimp
06-14-2000, 09:50 AM
I've now also figured out #1. #2 is all I need help with, please help. thank you.

------------------
If you think an education is expensive...try ignorance.

artsapimp
06-14-2000, 07:20 PM
That makes sense, thanks.

I do have a rich text box on my system. I will play with that and search the net for a while before I ask any more questions about that. Thanks.

------------------
If you think an education is expensive...try ignorance.

Felix
06-14-2000, 10:27 PM
art,

you can't do tag coloring with the standard text box. You need the Rich Text Box for this, which is another ocx control. Of course it is a little harder to code since it has more functionality.

Maybe the rich text box is already on your computer? It could have been installed with some shareware made with VB. Check your ocx control list (somewhere in the menu, I don't have VB on that system right now) and mark the checkbox to add the rich text box to your tool bar.

If you don't have the richt text box on your computer, let me know, I'll grab it and email it to you.

Beside, unfortunately I have no personal experience in coding the rich text box, so I can't help you with coding it. http://www.pcmech.com/ubb/frown.gif

artsapimp
06-15-2000, 11:41 AM
How do I make the typing on one line of a RichTextBox continue without wrapping onto the next line? Thanks

------------------
If you think an education is expensive...try ignorance.

Felix
06-15-2000, 01:31 PM
I assume you can set this using a certain property. Open the object catalogue, select "Rich Text Box" in the top list, and browse all properties and methods to see its short descriptions. It's usually very informative. Good luck! I'll bet you'll get it out http://www.pcmech.com/ubb/biggrin.gif