How Do I is your introduction to important task-based topics about Visual Basic programming and application development. The major categories of what you can do with Visual Basic are listed in this topic. The links lead you to important procedure-based Help pages.
Upgrade a Visual Basic 6.0 Application … Learn the .NET Framework … more
Object-oriented Programming … Manage Control Flow … Work with Variables … Handle Errors and Exceptions … more
Forms and Controls … Data … Printing … more
Language-Integrated Query ... LINQ to Objects ... LINQ to SQL ... LINQ to XML ... LINQ to DataSet ... more
Getting Started … Load Data … Validate Data … more
Deploy with ClickOnce … Create a CD for My Program … Send a Program through E-mail … more
Web Applications … Windows-based Applications …Components … more
Debug Applications … Monitor Applications … more
How do I set a textbox to a number value such as an Integer?There are several ways of going about this... The most basic way is to do a simple conversion, ike so:
Cint(textbox1.text)
This code is just used anywhere you would usually place
Textbox1.text
Rob =]
WebBrowser1.Navigate(NavBox.Text)
This one is not hard, all you have to do is use the KeyDown event instead... for example
Private Sub Form1_KeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)Handles Me.KeyDownIf e.keyvalue = keys.enter thenWebBrowser1.navigate(NavBox.text)End if
Have Fun!Rob =]
If you're aiming to display the outcome to the user rather than print it (to a printer), i'd recommend creating a list box called LstResults (Or whatever you wish, making sure you change the code accordingly) and using this code:for i = 1 to 20 step 2 LstResults.items.add(i & " = " i^2) 'Adds a new row to the listbox containing the value of i, an equals sign and then the value of i squarednext iHope this helps.Answer by Antileech
HELP!!!! HELP!!! HELP !!!! How do I code the + , - and * buttons for a calculator? How do I code the text boxes for the numbers/text box,.. and for the 'sum' text box so it's cleared every time you put a diff. number in to add an subtract? Do you take out all the exisiting code that's between the Private Sub and the "end" ????? or do you leave in the existing code and add to it whatever's supposed to be IN there,.. and what IS supposed to be in there ?! our text book is NO HELP and Microsoft's help is NO HELP!!!! UUUUGGGGGH!!!!!First of all, when you deal with textboxes and +/- you need to make them into integers, which is done by replacing TextboxAnswer.text or ButtonOne.text in your code with Cint(TextboxAnswer.text) etc.Also, you need to place the following code in the event for the Equal button press
TextboxAnwer.text = ""
that clears it.If you want, just before that line, you could include a variable to make the original sum hang around:
Public answer as integer = 0Private Sub Equals_pressed(byval e as system.eventargs)Handles Equals.pressedAnswer = CInt(TextboxAnswer.text)TextboxAnswer.text = ""End Sub
Yes it may sound sad but how do i fix the "end statment expected" error?Try defining your variable value within the line such as:
Dim VariableName As Integer = TextBox1.Text
I have a form with a disabled button and a normal text box. I want to make it so when the text box says something the button becomes enabled. For example if the text box says password then the button would become enabledDefine your password first
Public Password as string = "Password"
Then in the TextChanged event for the TextBox
Private Sub TextBox_TextChanged(ByVal e as system.eventargs) handles textbox1.textchangedIf textbox1.text = "Password" thenButton1.enabled = trueelsebutton1.enabled = falseend if
Simple form with 2 buttonsFirst button starts code running (say updating the value in a text box)Second button stops the codeProblem I have is that form has lost focus so how do I effectively allow other things to happen while code runs - it's not multi-threading is is?Thinking about it I could have a seperate process in another app to change a value which the running code tests for but that's very cumbersome! Heres a basic Layout to do this:Ingredients:2 Buttons (1 Says Start Other Says Stop)1 Textbox or NumericUpDown1 TimerCode:Timer 1:
PrivateSub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
NumericUpDown1.Value = NumericUpDown1.Value + 1Textbox.Text = TextBox1.Text + Val(1)
EndSub
Start Button:
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickTimer1.Enabled = True EndSub
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickTimer1.Enabled = True
Stop Button:
PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Enabled = False
Very Simple VeeBeer
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesTextBox1.TextChanged If TextBox1.Text = "InputText" Then Button1.Text = "InputText" Button1.Enable = True Button2.Text = "" Button2.Enabled = False Elseif TextBox1.Text = "InputText" Then Button1.Text = "" Button1.Enabled = False Button2.Text = "InputText" Button2.Enabled = True End IfEnd Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesTextBox1.TextChanged
If TextBox1.Text = "InputText" Then
Button1.Text = "InputText" Button1.Enable = True Button2.Text = "" Button2.Enabled = False Elseif TextBox1.Text = "InputText" Then Button1.Text = "" Button1.Enabled = False Button2.Text = "InputText" Button2.Enabled = True End IfEnd Sub
my assignment is to create three textboxes and within each put text one for txtbox 1, two for txtbox2, and 3 for txtbox3. then code them so that when i click one , two , or three it focuses on it with a red forecolor. How do i go about coding them so that can happen? help pls.
may start time ,end time and elapsed time must be in "hh:mm:ss" format
How can i change my background (of my form) in runtime by pressing a button??Used an Image as background that is.Grtz & Thx
how do i use the lastIndexOf method. i want to remove just the file name from the filepath could someone please Help?
can be able to view a pdf in a form or use a object to display a pdfpreciate all the help thanks...
Private Sub Drive1_Change()Dir1.Path = Drive1.DriveEnd SubPrivate Sub Dir1_Change()File1.Path = Dir1.PathLabel1.Caption = File1.PathEnd SubPrivate Sub File1_Click()Label1.Caption = File1.Path & " " & File1.FileNameEnd Sub
How do I print the sum of numbers divisible by 5 IE (10,25,ETC )
Hi,1. i am trying to add a connection to a database file using vb 2008.when i right click Data connection then click add connection and select MS Access Database file i dont get the option to browse for my access file.2. in college i could browse for the file and select it but when i right clicked on the entries i didnt get the option to retrive data. just copy, refresh and paste. can you hep you help debug my brain of these two problems