5 Replies - 2329 Views - Last Post: 30 August 2009 - 12:30 PM Rate Topic: -----

#1 Aerosolus  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 29-August 09

Multi Line Textboxes and Multiple Output

Posted 29 August 2009 - 08:30 AM

Hi everyone, i have searched the forum but have not been able to find a solution as to what i need to acheive.


What i want to do is have 2 Multi line textboxes.

In the first textbox i want to be able to paste multiple urls.
Example:
url1
url2
url3
url4
etc etc..

and in the second textbox i would like the output to go like this:

<a href=URL1 target=blank>Link1</a>
<a href=URL2 target=blank>Link2</a>
<a href=URL3 target=blank>Link3</a>
<a href=URL4 target=blank>Link4</a>


So far all ive gotten is this

Private Sub Command1_Click()

	Dim strProperties As String
   
	strProperties = Text1.Text & vbNewLine
   
	strProperties = "<a href=" & strProperties & " target=blank>Link 1</a>"
		
	Text2.Text = strProperties

End Sub


When i click the command button all that is displayed in the textbox 2 is, which isnt even displayed on a single line:

<a href=Text1
 target=blank>Link 1</a>


if i paste multiple links i get the following:

<a href=url1
url2
url3
url4
 target=blank>Link 1</a>


Im very new to this and i really need some help with this!

Huge thanks in advance!!! :)

This post has been edited by Aerosolus: 29 August 2009 - 08:32 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Multi Line Textboxes and Multiple Output

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 469
  • View blog
  • Posts: 4,280
  • Joined: 25-March 09

Re: Multi Line Textboxes and Multiple Output

Posted 29 August 2009 - 11:50 AM

that is becose when you do this
strProperties = Text1.Text & vbNewLine



you put the other multyline textbox with all vbNewLine with it if you put this in your code you will see what i mean
 strProperties = Text1.Text & vbNewLine
 debug.print strProperties 



now this is what i make in fast i hope it will works for you
Private Sub Command1_Click()

	Dim strProperties As String
	Dim i As Integer
	Dim l As Integer
	Text2.Text = ""
	For i = 1 To Len(Text1.Text)
		l = InStr(i, Text1.Text, vbNewLine)
		If l <> Len(Text1.Text) And l <> 0 Then
			strProperties = Mid(Text1.Text, i, (l - i))
			strProperties = "<a href=" & strProperties & " target=blank>Link 1</a>"
			Text2.Text = Text2.Text & strProperties & vbNewLine
		Else
		If l = 0 Then
			strProperties = Mid(Text1.Text, i, ((Len(Text1.Text) + 1) - i))
			strProperties = "<a href=" & strProperties & " target=blank>Link 1</a>"
			Text2.Text = Text2.Text & strProperties & vbNewLine
			Exit For
		Else
			Exit For
		End If
		End If
		i = l + 1
	Next i
   
End Sub




Good Luck and let me know if it works for you :)
best wishes

This post has been edited by NoBrain: 29 August 2009 - 11:51 AM

Was This Post Helpful? 1
  • +
  • -

#3 Aerosolus  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 29-August 09

Re: Multi Line Textboxes and Multiple Output

Posted 29 August 2009 - 04:58 PM

Hey NoBrain,

Thank you ever so much for helping me out!

I just have one more question, how can i get the Link name to change. If i paste in 4 links now it outputs them all like this:

<a href=URL1 target=blank>Link1</a>
<a href=URL2 target=blank>Link1</a>
<a href=URL3 target=blank>Link1</a>
<a href=URL4 target=blank>Link1</a>



If it could output them like this, that would be just perfect:

<a href=URL1 target=blank>Link1</a>
<a href=URL2 target=blank>Link2</a>
<a href=URL3 target=blank>Link3</a>
<a href=URL4 target=blank>Link4</a>
etc etc


Ive tried a few things but they have messed up the perfect output of links :crazy:

Again thank you for taking the time to help me out here, i really appreciate it!
I would never have been able to figure that code out! :)

This post has been edited by Aerosolus: 29 August 2009 - 05:13 PM

Was This Post Helpful? 0
  • +
  • -

#4 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 469
  • View blog
  • Posts: 4,280
  • Joined: 25-March 09

Re: Multi Line Textboxes and Multiple Output

Posted 30 August 2009 - 05:44 AM

hi dude :) it is rly simple you just need to have a counter for each new line becose if you have 4 urls they will be 4 lines :) so here is how it is done :)

Private Sub Command1_Click()

	Dim strProperties As String
	Dim i As Integer
	Dim l As Integer
	Dim lineCount As Integer  'Counter for each line that have text in it'
	
	lineCount = 0
	Text2.Text = ""
	For i = 1 To Len(Text1.Text)
	lineCount = lineCount + 1
		l = InStr(i, Text1.Text, vbNewLine)
		If l <> Len(Text1.Text) And l <> 0 Then
			strProperties = Mid(Text1.Text, i, (l - i))
			strProperties = "<a href=" & strProperties & " target=blank>Link" & lineCount & "</a>"
			Text2.Text = Text2.Text & strProperties & vbNewLine
			Debug.Print Text2.Text
		Else
		If l = 0 Then
			strProperties = Mid(Text1.Text, i, ((Len(Text1.Text) + 1) - i))
			strProperties = "<a href=" & strProperties & " target=blank>Link" & lineCount & "</a>"
			Text2.Text = Text2.Text & strProperties & vbNewLine
			Exit For
			Debug.Print Text2.Text
		Else
			Exit For
		End If
		End If
		i = l + 1
	Next i
   
End Sub




good luck dude :)
Was This Post Helpful? 1
  • +
  • -

#5 Aerosolus  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 29-August 09

Re: Multi Line Textboxes and Multiple Output

Posted 30 August 2009 - 06:43 AM

NoBrain your awesome, thanks for the fantastic help!
This will save me so much time, i used to have to manually code links, which was really annoying (especially when you had 20+ links lol)

Thanks once again! :)
Was This Post Helpful? 0
  • +
  • -

#6 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 469
  • View blog
  • Posts: 4,280
  • Joined: 25-March 09

Re: Multi Line Textboxes and Multiple Output

Posted 30 August 2009 - 12:30 PM

np :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1