Results 1 to 7 of 7

Thread: Vb Task

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    4

    Vb Task

    Any danish people in this forum?

    Need help with a task.

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Vb Task

    Why do you want help from danish people only? This is a forum with people from all over the world, so english should always be used when posting.

    You could describe your problem here and we'll try to help you the best we can.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    4

    Re: Vb Task

    It is because my english is very bad. But I'll try then.

    The is a describtion of my task.

    Make a funktion their can calculate, a salsman's provision. Then I have the sale, and the commision.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Vb Task

    First off, that's better English than a lot of native speakers can manage to post.

    As to the question, surely that's just a matter of finding a percentage. Multiplying a number and then dividing by 100 is the same all over, whether it's for sales commission or something else.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    4

    Re: Vb Task

    Public Function footbar(Sales As Integer) As Integer
    Dim X As Integer

    If (">500") Then GoTo 3

    ElseIf Sales >= 500 And Sales <= 1000 Then
    komm = 6
    ElseIf Sales >= 1000 And Sales <= 2000 Then
    komm = 9
    ElseIf Sales >= 2000 And Sales <= 5000 Then
    komm = 12
    Else
    If Sales >= 5000 Then komm 15


    End If


    End Function


    Can somebody tell me, what is wrong? When I compile, it says: "Compile Error" "Else without if"

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Vb Task

    This line:
    vb.net Code:
    1. If (">500") Then GoTo 3
    is a self-contained statement. You cannot add an Else to that on another line. If you put anything after the "Then" part then it all has to be on the same line. If you want to use multiple lines then you can't have anything after the "Then" on the same line.

    That said, that code cant' do anything useful. What is that line going to do? It's checking the string ">500" and trying to evaluate ti as a Boolean. That just isn't going to do anything useful. Presumably you want to compare Sales to 500, but you're not doing anything like that. Also, there's really no justifiable reason for using a GoTo anywhere these days, and certainly not there. If you have a sliding scale then it should look like this:
    vb.net Code:
    1. If sales < 500 Then
    2.     'Do nothing.
    3. ElseIf sales < 1000 Then
    4.  
    5. ElseIf sales < 2000 Then
    6.  
    7. ElseIf sales < 5000 Then
    8.  
    9. Else
    10.  
    11. End If
    or this:
    vb.net Code:
    1. Select Case sales
    2.     Case Is < 500
    3.         'Do nothing.
    4.     Case Is < 1000
    5.  
    6.     Case Is < 2000
    7.  
    8.     Case Is < 5000
    9.  
    10.     Case Else
    11.  
    12. End Select
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    4

    Re: Vb Task

    Ok, It works now. Thanks for the help!

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