VB.NET Tutorial - List Collections - Adding, Retrieving, and Removing Data (Visual Basic .NET)

  Рет қаралды 46,078

VB Toolbox

VB Toolbox

Күн бұрын

Пікірлер: 43
@ga7853
@ga7853 8 жыл бұрын
This Techniques that you explained which is CollectionName.Foreach(addressof FunctionName) is really great, thank you teaching it to us, I really did not know that it exists.Thank you for those new things, its really helpful.
@dajo77
@dajo77 10 жыл бұрын
Very nice, helped a lot! Say one already has some data that they would like insert into the list, how would you preload from a class in order to keep the main form more clean?
@VBToolbox
@VBToolbox 10 жыл бұрын
You could easily populate your list with values from a text file (.txt,.csv,etc.) at runtime using the StreamReader. This would keep your code clean and also allow you to easily change any of those values outside of the application if you wanted to. If you prefer to use a class, string, or something similar, you can certainly do that as well; However, if you already have a class fully loaded with variables containing your list values, you could just use an instance of that class and abandon the collection altogether.
@manishkishoresharma
@manishkishoresharma 9 жыл бұрын
Really Really Nice Video. And i Would like to thank u sir for this....
@AardaerimusDAritonyss
@AardaerimusDAritonyss 9 жыл бұрын
+Manish kishore sharma Thank you for the encouraging comment, Manish. :-)
@manishkishoresharma
@manishkishoresharma 8 жыл бұрын
Sir I am thank full to you. because you have demonstrated the thing this way like even a novice can get the topic very easily.
@CarlFritz24
@CarlFritz24 10 жыл бұрын
Very good. Once again... perfectly explained and made simple. Only a question: After saving the file to an executable, the items go within the executable ? Also saved ?
@VBToolbox
@VBToolbox 10 жыл бұрын
Thanks again, Carlos. :-) In this example, the items that are added programmatically via MyStrList.Add() would be stored/saved when the application was compiled. Anything that is added _after_ compiling will not be saved, unless you add a way to save outside of the application (database, text file, etc.).
@buddyroach
@buddyroach 9 жыл бұрын
VB Toolbox such as using my.settings
@kcvinu
@kcvinu 4 жыл бұрын
Hi, Thanks for the videos. Any plans to publish a video on Async Await & Task class in VB .Net ?
@VBToolbox
@VBToolbox 4 жыл бұрын
Unfortunately, production is kind of dead in the water until I have electricity and and reliable internet again.
@kcvinu
@kcvinu 4 жыл бұрын
@@VBToolbox Oh, I am so sorry about that. I hope the situation will be better soon. :)
@buddyroach
@buddyroach 9 жыл бұрын
very good tutorial. easy to understand. thanks. i have a question though. i have a picturebox control which is part of a list collection. how do i reference it without referencing it tostring? i want to be able to change properties of the pictureboxes in the list.
@buddyroach
@buddyroach 9 жыл бұрын
buddyroach Unable to cast object of type 'System.Windows.Forms.Button' to type 'System.Windows.Forms.PictureBox'.
@VBToolbox
@VBToolbox 9 жыл бұрын
buddyroach Are you actually storing it to your List as a PictureBox? [e.g., Private lstPictureBoxes New List(Of PictureBox) ] If so, you should be able to reference their properties directly or via lambda expression. If you're just storing the Names of PictureBoxes as a string to the List, then you could call the controls by name from the Form's Control collection. Let me know if you need a demo. :-)
@buddyroach
@buddyroach 9 жыл бұрын
VB Toolbox yes i am storing the pictureboxes themselves to the list because the user creates them. im using this: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim canvas = New PictureBox canvases.Add(canvas) canvas.Name = "canvas" & canvases.Count.ToString() canvas.BackColor = Color.White canvas.BorderStyle = BorderStyle.FixedSingle canvas.Image = Nothing canvas.Height = TextBox2.Text canvas.Width = TextBox1.Text AddHandler canvas.MouseDown, AddressOf PictureBox1_MouseDown AddHandler canvas.MouseUp, AddressOf PictureBox1_MouseUp AddHandler canvas.MouseMove, AddressOf PictureBox1_MouseMove canvas.Top = Panel2.Bottom canvas.Left = Panel1.Right Controls.Add(canvas) Panel3.Visible = False Catch ex As Exception End Try My.Settings.canvaswidth = TextBox1.Text My.Settings.canvasheight = TextBox2.Text My.Settings.Save() ComboBox1.Items.Clear() For Each C In canvases ComboBox1.Items.Add(C.Name) ComboBox1.SelectedItem = C.Name C.BringToFront() Next ComboBox1.SelectedItem = My.Settings.selectedcanvas End Sub thanks...
@buddyroach
@buddyroach 9 жыл бұрын
buddyroach oh, and of course in public class at top i did: Dim canvases As New List(Of PictureBox)
@VBToolbox
@VBToolbox 9 жыл бұрын
buddyroach Sorry for the slow replies. I'm super buried at work right now, but I'll try to help out with this as soon as I'm able. :-)
@brownstamp8894
@brownstamp8894 8 жыл бұрын
Thank you for ur guiding, It is really helpful to the beginner of Visual base like me. I have saw this code before when i learning to make Mario for those uncountable monster. However i couldn't make it clear how it works at that time. Got a question, I want to show out what is in the list anytime, so i make a timer tick to updating data to ListBox1.. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick MyStrList.ForEach(AddressOf ListBox1) End Sub However, this doesn't work. Have i do something wrong in this code? Or it is unthinkable to combine timer with list-out?
@VBToolbox
@VBToolbox 8 жыл бұрын
It would probably be more efficient to have a Sub to refresh the listbox contents whenever the list is manipulated. That way you don't have a timer constantly recycling the list even if nothing is changed. Example: [Refresh the ListBox] Private Sub RefreshListBox() ListBox1.Items.Clear() MyStrList.ForEach(Sub(i) ListBox1.Items.Add(i)) ListBox1.Sorted = True End Sub [Remove an item from the list and refresh the ListBox] Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click MyStrList.RemoveAt(1) RefreshListBox() End Sub
@xxapoloxx
@xxapoloxx 3 жыл бұрын
how does a list implement the equals method
@sergiosmfyo
@sergiosmfyo 8 жыл бұрын
Hi, how are you? I've got one question. Can this collection be used for containing all forms in the project(those closed or open). And would it be posible to show a chosen form? I'm trying to show some forms without using the openforms method because these forms aren't open :(. Could you, please make a video tutorial to show that with a listbox?
@exocrypton6440
@exocrypton6440 9 жыл бұрын
Is it possible that other members can also add(view, etc.) strings to the list?
@VBToolbox
@VBToolbox 9 жыл бұрын
exocrypton Due to the fact that the collection exists only in the memory of the computer running the application, the only way that another user could access the list is via a client/server application. For multi-client or multi-user access, it would be much easier to use a database.
@exocrypton6440
@exocrypton6440 9 жыл бұрын
VB Toolbox I thought of a Database that works with e.g. a ListView via MySQL, does that work?
@VBToolbox
@VBToolbox 9 жыл бұрын
Yep. :-) With a database connection you can do a lot of different things. I prefer a DataGridView over a ListView, but that depends entirely upon your needs.
@wardude202
@wardude202 9 жыл бұрын
Quick question, how do i remove a specific line from the list? what would be the code for that e.g say you have 3 different things in the list, and you want to remove the second one and replace it with something else, how do i go about doing that?
@VBToolbox
@VBToolbox 9 жыл бұрын
Wardude202 This will depend upon a couple of things like what data type is in your list, and whether you know the position (index) of the item that you want to change. The simplest method is to just set the new value by its index: Example [List Of String] MyList(3) = "Awesome" That would replace the 4th item in the list with "Awesome" and preserve its position in the list. If you're using custom data types and looping the values you cannot alter their indexes directly; However, you can use a little magic and convert the List to a copy of itself and use the current index position to alter the original. _For Each item In MyList.ToList_
@heenarelan9971
@heenarelan9971 5 жыл бұрын
Hi.. can u help with the list things?
@elkolodj1
@elkolodj1 9 жыл бұрын
Hi, do you know how to populate a string array with data from a sharepoint list. My goal is to populate a listbox in a windows form with this data every time a user uses the form. sorry if this is a dumb question I'm very new to vb
@VBToolbox
@VBToolbox 9 жыл бұрын
elkolodj1 I'm sorry, elkolodj1. Unfortunately, I have no experience with Sharepoint lists. Perhaps someone else around here might know? Adding values to a list or array is generally easy enough. With a List you can simply use the Add() method: Dim lst As New List(Of String) lst.Add("mySharepointValue") If you're using an array you may need to redefine (ReDim) to increase its indexes.
@elkolodj1
@elkolodj1 9 жыл бұрын
Thanks, I solved with a workaround creating a connection that gets the recordset for the fields in the sharepoint list. I thought it was easier, but i solved it now. Thanks!
@arsenewenger9351
@arsenewenger9351 9 жыл бұрын
instead of a message box how does one show the contents of a list to a textbox
@VBToolbox
@VBToolbox 9 жыл бұрын
+Mark Watson Hello, Mark. :-) Simply add a TextBox to your form and set its "Multiline" property to "True", then use the following: For Each s In MyStrList TextBox1.AppendText(s & vbNewLine) Next Or if you're on VB 2010+ you can shorten to one line: MyStrList.ForEach(Sub(s) TextBox1.AppendText(s & vbNewLine)) If you want a specific line index in a single-line textbox: TextBox1.Text = MyStrList(0) 'Displays the first item in your List I hope that helps!
@arsenewenger9351
@arsenewenger9351 9 жыл бұрын
Thankyou very much!
@VBToolbox
@VBToolbox 9 жыл бұрын
+Mark Watson Happy to help out!
@TheVideoVolcano
@TheVideoVolcano 7 жыл бұрын
Woah I thought I knew vb.net, I've been trying all the methods I wouldn't touch, I would do it like... For Each s In MyStrList TextBox1.text &= (s & vbCrLf) Next All the lambda expressions i didn't know vb.net even supported
@VictorHernandez-vq5hx
@VictorHernandez-vq5hx 4 жыл бұрын
excelente, como lo podría hacer un While sdr.Read()
@renefrijhoff2484
@renefrijhoff2484 6 жыл бұрын
Nice explained, but I don't have a use for this as it's only a single dimension.
@jmbustosarg
@jmbustosarg 7 жыл бұрын
Thanks u!!!!!!!! Great job
@tekilagerila2447
@tekilagerila2447 9 жыл бұрын
nice
@baherwahby22
@baherwahby22 Жыл бұрын
Another great video if you do.nt say where you learn or the names of the books which explaining all this staf i will kill my self
@VBToolbox
@VBToolbox Жыл бұрын
Hi baherwahby22, I answered on your other comments. I only learned by playing around and sometimes searching on specific problems if I get stuck - no books, no school.
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН