Announcement

Collapse
No announcement yet.

visual basic HELLLLPPP!!!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • visual basic HELLLLPPP!!!

    hey all im doing batchelor of IT externally at uni at the moment and i am learning basic visual basic and im stuck and need help... is there anyone out there who can use visual basic really well

    basically i am trying to make a simple calculator but i get stuck at the text boxes

    ive got 3 text boxes with labels and a button
    i need the user to be able to input a variable and then the button to add the 3 variables together
    at the moment i cant get passed the dim stage everytime i try to dim as integer i get underlines (which means no good) im not sure where i get the label from i tried this


    Code:
    Dim no1 As Integer
    no1 being the name of the input text box

    Code:
    Dim label1 As Integer
    label1 being the name of the label next to the text box.

    i feel so stupid!!!

  • #2
    Did you create Sub for the button click by any chance?

    Comment


    • #3
      Code:
      Public Class Form1
      
      
          Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
              Dim no1 As Integer
              Dim label1 As Integer
      
      
          End Sub
      End Class

      Comment


      • #4
        is one of you labels called "label1"? if so you can't use it for the name of your integer.
        From what you have asked you have 3 labels likely called "label1", "label2" and "label3" the 3 textboxes will also have similar names. "Textbox1" etc.
        you can't use any of these name when decalring values.

        Comment


        • #5
          From memory you want to declare 3 variables and then make their values whatever is in the text box

          This isnt the exact code and I cant tell you off the top of my head because its been a LONG time since I did anything like this but you have to do it like this from memory:

          Private Sub Command1_Click ( )

          Dim no1 as integer
          Dim no2 as integer
          Dim no3 as integer

          no1 = "Whatever is in box 1"
          no2 = "Whatever is in box 2"
          no3 = "Whatever is in box 3"

          print no1 + no2 + no3 in the box you have for the answer.

          Basically the label of the boxes is NOT your variable name, they are the box name. You can show the data of a variable in these boxes or you can make a variable take it's value from whatever is in these boxes but you cant make the box itself a variable.

          Comment

          Working...
          X