Results 1 to 8 of 8

Thread: Elementary Text Box question.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    323
    I am new to VB and am trying to make a very simple program for school. I need some very basic things. I have a form with 3 text boxes, a command button, and a label. Text1, Text2, Text3, Label1, Command1.

    1. int4 = (int1, int2, int3) / 100

    I have started with:

    Dim....

    for each as an integer. I then <i>thought</i> I could type:

    int1 = text1.text

    I was wrong. Invalid outside procedure. What would I type there? Thanks.

    If you think education is expensive, try ignorance.

  2. #2
    Guest
    Are you sure the character's in the TextBox's are numbers when you assigned them to int1?


  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    323
    It's as soon as I hit the play button to test the script it gives me the error.
    If you think education is expensive, try ignorance.

  4. #4
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655

    Thumbs up

    Well if your wanting label1 to be equal to the equation when you click the button try this:

    Code:
    Private Sub Command1_Click()
    Label1.Caption = (CInt(Text1.Text) + CInt(Text2.Text) + CInt(Text3.Text)) / 100
    End Sub
    If not, give some more information so I can help you better.
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    323
    That is exactly it, thanks
    If you think education is expensive, try ignorance.

  6. #6
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    Your welcome. If you need anything else, just let me know.
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Invalid outside procedure occurs when you have snippets of code outside your procedures. Also Cint will round towards nearest whole and .5 up. Using INT will allow you to round down, in other words, remove the decimal parts
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    'or'

    Label1.Caption = (Val(Text1) + Val(Text2) + Val(Text3)) / 100
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width