vb.net-2010

passing all the items of listbox in the richtextbox

牧云@^-^@ 提交于 2019-12-24 11:37:59
问题 how can I pass the items of listbox to richtextbox?. I have multiple items and I want it to display in the richtextbox. this items is like a receipt. it display the items along with its amount. 回答1: This is just a way to do it, using LINQ : Dim Items As String() = From s As String In ListBox1.Items RichTextBox1.Text = String.Join(Environment.NewLine, Items) 回答2: One of the problems doing this with a listbox, is that listboxes store the items as objects and uses the ToString method of each

Select any random string from a list

怎甘沉沦 提交于 2019-12-24 02:23:38
问题 How can I select any random string from a given list of strings? Example: List1: banana, apple, pineapple, mango, dragon-fruit List2: 10.2.0.212, 10.4.0.221, 10.2.0.223 When I call some function like randomize(List1) = somevar then it will just take any string from that particular list. The result in somevar will be totally random. How can it be done? Thank you very much :) 回答1: Use Random Dim rnd = new Random() Dim randomFruit = List1(rnd.Next(0, List1.Count)) Note that you have to reuse the

parse text file and remove commas inside double quotes

99封情书 提交于 2019-12-23 18:07:00
问题 I have a text file that needs to be converted into a csv file. My plan is to: parse the file line by line search and replace commas inside double quotes with a space then delete all double quotes append the line to a new csv file Question: I need a function that will recognize the comma inside a double quote and replace it. Here is a sample line: "MRS Brown","4611 BEAUMONT ST"," ","WARRIOR RUN, PA" 回答1: Your file seems to be already in a CSV complaint format. Any good CSV reader would be able

Filling a DataGridView from SQLReader

雨燕双飞 提交于 2019-12-23 09:18:22
问题 Im a little stuck on some code that im writing An outline is that i am reading some data in from an SQL database and wantint to display it in a DataGridView on a form. I have confirmed that there is data being returned from the database but am unsure as to why this isnt appearing. I have followed a number of tutorials from the internet but so far non have worked here is my code Private Sub PopulateGrid() Dim Con As New SqlClient.SqlConnection Dim strCon As String = CropTrackMod.strConn Dim

Button Click Equals to Press Enter Key on the Keyboard

可紊 提交于 2019-12-23 06:36:46
问题 I would like to equal a click on Button1 to press the Enter key on the keyboard, how can I do that? Can you provide me the code please? Thanks in advance.. 回答1: Set the AcceptButton property of your form to be Button1 Documentation here 回答2: I belive this is what he's looking for: Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click SendKeys.Send("{ENTER}") End Sub As I understand it he wanted a button to press Enter for him, not that

Button Click Equals to Press Enter Key on the Keyboard

爱⌒轻易说出口 提交于 2019-12-23 06:36:08
问题 I would like to equal a click on Button1 to press the Enter key on the keyboard, how can I do that? Can you provide me the code please? Thanks in advance.. 回答1: Set the AcceptButton property of your form to be Button1 Documentation here 回答2: I belive this is what he's looking for: Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click SendKeys.Send("{ENTER}") End Sub As I understand it he wanted a button to press Enter for him, not that

Checkbox events when Form is opened and closed fire when form is reloaded

烈酒焚心 提交于 2019-12-23 04:22:05
问题 First... I am open to skinning this cat a different way if I am going at it wrong to begin with. Using VB 2010 .net 4.0 and I am very much a beginner. I am making a product billing application that has a main form and a subform with additional options. Whenever that subform is reopened after being opened once, the checkbox events that were selected are blank by default. If I recheck them (so someone can uncheck) then any that are rechecked all refire and increase the variable again. I

BC30451: 'MailValidation' is not declared. It may be inaccessible due to its protection level

ε祈祈猫儿з 提交于 2019-12-23 02:47:12
问题 I am using this code in my aspx file: <%MailValidation(Email.Text)%> <asp:RegularExpressionValidator runat="server" ID="RegExpValidator" CssClass="failureNotification" ControlToValidate="Email" ValidationGroup="RegisterUserValidationGroup">*</asp:RegularExpressionValidator> And also I have the following in my code behind: Public Sub MailValidation(mail As String) 'Dim retVal As String Dim s As Internet = New Internet If mail = "" Then RegExpValidator.ErrorMessage = Nothing RegExpValidator

Convert mm/dd/yyyy to yyyymmdd (VB.NET)

与世无争的帅哥 提交于 2019-12-22 04:42:33
问题 Is there any way I can convert a date of format: dd/mm/yyyy to yyyymmdd format? For example from : 25/07/2011 to 20110725? in VB.NET? 回答1: Dates themselves don't have formats inherently. You can parse a string into a DateTime by parsing it with dd/MM/yyyy format and then convert that into a string using yyyyMMdd format: DateTime date = DateTime.ParseExact(text, "dd/MM/yyyy", CultureInfo.InvariantCulture); string reformatted = date.ToString("yyyyMMdd", CultureInfo.InvariantCulture); Or in VB:

Displaying image from folder/file in vb.net

不羁的心 提交于 2019-12-21 12:09:03
问题 Dim ImagePath As String = "images/spaceship2.png" Dim img1 As Bitmap Dim newImage As Image = Image.FromFile("images/spaceship2.png") img1 = New Bitmap(ImagePath) pb2.ImageLocation = ImagePath pb1.Image = newImage I want to display image from folder, for example, student with an id number of 22137471, the picture with the name of 22137471 will be display on my picture box, between, i saw this code somewhere in google. 回答1: i want to display image from folder, for example, student with an id