KeedonKing's Profile
Reputation: 1
Apprentice
- Group:
- Active Members
- Active Posts:
- 57 (0.18 per day)
- Joined:
- 12-July 12
- Profile Views:
- 624
- Last Active:
Jan 22 2013 02:33 AM- Currently:
- Offline
Previous Fields
- Dream Kudos:
- 0
Posts I've Made
-
In Topic: Writing and reading from a TXT file to add information to buttons
Posted 21 Sep 2012
_HAWK_, on 20 September 2012 - 11:41 AM, said:So you are making a button for each line with the text for it being the first part up to the ~ and then store the rest in the .Tag property?
Using sr As New StreamReader(<path>) While Not sr.EndOfStream Dim str() As String = sr.Readline.Split("~"c) Dim btn As New Button btn.Text = str(0) btn.Tag = str(1) 'provide location logic 'add to a control collection 'add your delegates for events End While End Using
Thanks A bunch Hawk.... Works like a charm now both adding new streams, and loading old ones at startup. Thanks everyone for your patience with me.
Radio Load:
Using sr As New StreamReader("BtnSettings.txt", True) While Not sr.EndOfStream Dim str() As String = sr.ReadLine.Split("~"c) Dim btn As New Button btn.Text = str(0) btn.Tag = str(1) btn.Width = 95 AddHandler btn.Click, AddressOf ClickMe FlowLayoutPanel1.Controls.Add(btn) End While End Using
Add New Channel Button:
Using SWNames As StreamWriter = New StreamWriter("BtnSettings.txt", True) SWNames.WriteLine(TextBox1.Text & "~" & TextBox2.Text) End Using Using sr As New StreamReader("BtnSettings.txt", True) While Not sr.EndOfStream Dim str() As String = sr.ReadLine.Split("~"c) Dim btn As New Button btn.Text = str(0) btn.Tag = str(1) 'provide location logic 'add to a control collection 'add your delegates for events AddHandler btn.Click, AddressOf TVForm.ClickMe TVForm.FlowLayoutPanel1.Controls.Add(btn) End While End Using
Channel Button Click Event:
Public Sub ClickMe(ByVal Sender As Object, ByVal e As EventArgs) btn = CType(Sender, Button) TV.URL = btn.Tag End Sub -
In Topic: Writing and reading from a TXT file to add information to buttons
Posted 20 Sep 2012
Exactly Hawk.
Sorry for the Short talk man. Doing some work around this house of mine trying to organize for a family gathering. I appreciate the insight. -
In Topic: Writing and reading from a TXT file to add information to buttons
Posted 20 Sep 2012
_HAWK_, on 20 September 2012 - 08:30 AM, said:line = Streams.ReadLine.StartsWith(btn.Name) is a boolean check not a way to populate if correct. Others have asked you what the file structure looks like. If you don't at least supply a pseudo example that matches your exact format there is no way we can help guide you on reading the data.
Included A Snapshot of the txtfile Created. -
In Topic: Writing and reading from a TXT file to add information to buttons
Posted 19 Sep 2012
CharlieMay, on 19 September 2012 - 02:36 PM, said:Can you give use a screenshot of what your textfile looks like?
Also, instead of separating the elements of the line with " " maybe use a "~" so you can split that line and keep each element separate. Space may be used in your textboxes somewhere and will throw off the split.
But you're still putting this code in the wrong place. Where you have this code is after the button is created and its click event is attached to this area.
Ok so I am guessing I got this semi right here:
First I added a Button to the main form, called "Add A Channel" When clicked it opens My "AddChannel Form"
"AddChannel Forms" Code:
Public Class AddChannel Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim btn As New Button AddHandler btn.Click, AddressOf TVForm.ClickMe btn.Name = TextBox1.Text btn.Width = 80 btn.Height = 25 btn.Text = TextBox1.Text TVForm.FlowLayoutPanel1.Controls.Add(btn) Using SWNames As StreamWriter = New StreamWriter("BtnSettings.txt", True) SWNames.WriteLine(TextBox1.Text & "~" & TextBox2.Text) End Using btn = CType(sender, Button) Using Streams As StreamReader = New StreamReader("BtnSettings.txt") Dim line As String line = Streams.ReadLine.StartsWith(btn.Name) Do While (Not line Is Nothing) Streams.ReadLine.StartsWith(btn.Name) If Streams.ReadLine.StartsWith(btn.Name) Then 'Here I imagine I need to split the First Part of the Data from the text file to add the actual url to the tag property of my new button. btn.Tag = Streams.ReadLine End If Exit Do Loop End Using Me.Close() End Sub End Class
From here, it adds the New Btn to the FlowLayoutPanel. And Now the button is Titled (Whatever text was used in TextBox1)
And The New Btns Tag property Should Contain the url. I've attached an image of how my text file looks.
Ok, so now the button is in My flowlayoutPanel. I have this for my New Btns Click event:
Public Sub ClickMe(ByVal Sender As Object, ByVal e As EventArgs) btn = CType(Sender, Button) TV.URL = btn.Tag End Sub
I am trying to figure this out but if ya could explain to me with more detail I would appreciate it
I suck at this but I am getting better haha
THis is how my textfile is saving:
SkyRadio~http://www.181.fm/asx.php?station=181-kickincountry&style=mp3&description=Kickin%27%20Country -
In Topic: Writing and reading from a TXT file to add information to buttons
Posted 19 Sep 2012
I still don't get what I'm doing wrong here:
Public Sub ClickMe(ByVal Sender As Object, ByVal e As EventArgs) Dim btn As Button btn = CType(Sender, Button) Using Streams As StreamReader = New StreamReader("BtnStreams.txt") Dim line As String line = Streams.ReadLine.Contains(btn.Name) Do While (Not line Is Nothing) line = Streams.ReadLine.Contains(btn.Name) If line = Streams.ReadLine.Contains(btn.Name) Then TV.URL = (line = Streams.ReadLine.StartsWith("Http://")) End If Exit Do Loop End Using End Sub
My Information
- Member Title:
- D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
Contact Information
- E-mail:
- Click here to e-mail me
Friends
|
|


Find Topics
Find Posts
View Reputation Given

|
Comments
KeedonKing has no profile comments yet. Why not say hello?