I want to create a very simple login form is VB
All of the usernames are in a textfile on my webserver.
So first the program downloads that textfile with:
Dim wc As New WebClient()
Dim datawc.DownloadString("url.txt")
After that my program put the the text in a richbox with
RichTextBox1.Text = data
Then the programs checks if the text that is entered in the textbox is also in the richtextbox.
Now the problem is that if i fill in the textbox 1122, and in the richtextbox is 1133 that the program returns a correct response.
Sorry for my bad english
I just fixed it myself by using this condition
If data.Contains(TextBox1.Text) Then
Related
I want to save my textbox1.text in a notepad of my computer. And after saving that, I will save the next textbox1.text again. But I want it to be added to the same notepad. Anyone can help me on the code? Using VB net.
I have a one form with controls and all entries will be displayed on one textbox. I want to save that textbox but I don't know how.
You could use the File.AppendAllText method to save the text to a file:
Public Sub SaveTextToFile(FilePath As String, Text As String)
System.IO.File.AppendAllText(FilePath, Text)
End Sub
Here is an example of using the method:
SaveTextToFile("C:\New.txt", textBox1.Text)
I've created a form in VB that requests some entries and through those entries a body for an email is created. Now I have to make a button that opens the default email client of the computer and populates the Body with the text that is generated through the form (I don't want it to send the email since the user is supposed to add the From and the Subject). I've managed to make it happen through this simple line :
Dim Text As String = Textbox1.Text
Process.Start("mailto:email#email.com?subject=Hello&body=" & Text)
However, when the email client opens the format of the body is messed up. There are supposed to be paragraphs and spaces but there aren't any. Can you help me fix this ?
In order for MailTo to work properly, you need to URL Encode your message. The following should work:
Dim Text As String = Textbox1.Text
Process.Start("mailto:email#email.com?subject=Hello&body=" & System.Web.HttpUtility.UrlEncode(Text))
In my application, a list of fields is read from a database, and then rendered in a TabControlPage. Each field has a Control of a specific type, one of which is a RichTextBox.
What I need, is when the user selects the RichTextBox, an OpenFileDialog should appear, allowing the user to select a file. The RichTextBox should then display the full path + filename(eg. C:/files/excel/thing.xlsx) in the form of a hyperlink.
Currently, you can type in the path+filename into the RichTextBox and it will automatically be made into a hyperlink.
Any suggestions, or perhaps reference material you can give me?
You can attach something like this to the Enter event on your RichTextBox:
Dim dialog As New OpenFileDialog()
Dim result As DialogResult = dialog.ShowDialog()
If result = Windows.Forms.DialogResult.OK Then
RichTextBox1.Text = dialog.FileName
End If
This is not turning it into a hyperlink for me, but it sounds like you have that part handled?
edited as per Lars' comment.
Ok so i'm trying to make multiple webrequests, but in a different way.
i'm trying to let my users add the websites on each line of a richtextbox and when they click a button it will run this:
Dim request As WebRequest = WebRequest.Create("Website")
But not for the hole richtextbox, but for every line, so say the richtextbox has all these lines:
google.com
facebook.com
youtube.com
and once they click the button, those sites will be put into the space where it says Website.
If anyone can help me with this, thank you!
Also sorry if this is messy, I don't think there's any other way to present this information!
This could get you started. Textboxes have a Lines property that contains a collection of strings from each line of the textbox (See this MSDN page for reference)
Dim arrUrls() As String = RichTextBox1.Lines
For i As Integer = 0 To UBound(arrUrls)
If Not arrUrls(i).Length=0 Then Dim request As System.Net.WebRequest = System.Net.WebRequest.Create(arrUrls(i))
Next
I am totally new to VB as I have just started to learn it.
I have already created a user form with an input text box and a button. I want to be able to scan a barcode and implement it into this link: http://openean.kaufkauf.net/?ean=\[ean\]&cmd=query&queryid=200000000 replacing [ean] with the numbers from the barcode.
Afterwards make a HTTP GET request and having the result pop up in a message box. I do not know how to take the value of the text box, paste it into the link and make the request.
Assuming your text box is named TextBox1, try:
Dim request As String = String.Format("http://openean.kaufkauf.net/?ean={0}&cmd=query&queryid=200000000", TextBox1.Text)
Dim webClient As New System.Net.WebClient
Dim result As String = webClient.DownloadString(request)
MessageBox.Show(result)
Note that the above code will wait for the result from the server before allowing the user to interact with the application again, but it's enough to get you started.