0 Replies - 7076 Views - Last Post: 08 January 2012 - 11:35 AM

#1 m_hatcher  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 57
  • Joined: 12-December 09

Simple addition Issue

Posted 08 January 2012 - 11:35 AM

I am working on a simple trivia app to get my feet wet in the app development area and I have ran into a issue I cant seem to work through. I had created a vb application awhile back that was your run of the mill movie quote trivia game and I had no issues with it. I decided to use the same basis for my app. I started porting things into my app and I keep getting errors when I try to use operators in my code. I first had a issue comparing 2 strings but I found a way around that by using String.Equals. Now I am trying to add some basic numbers and it keeps throwing errors about
Requested operation is not available because the runtime library function 'Microsoft.VisualBasic.CompilerServices.Operators.AddObject' is not defined.



I am also getting one when I try to multiply 2 numbers.
Am I completely overlooking something that I should be seeing. Thanks in advance

Partial Public Class MainPage
    Inherits PhoneApplicationPage

    'initalizes array with 20 blank strings
    Private quote(19) As String
    Private movie(19) As String
    'public variables to be used from all Functions and Subs
    Dim rndRandom As New Random
    Dim newRandomNumber As Integer
    Dim numberCorrect As Decimal = 0
    Dim numberIncorrect As Decimal = 0
    Dim totalAnswered As Decimal = 0
    Dim counter As Integer = 0

    ' Constructor
    Public Sub New()
        InitializeComponent()
    End Sub

    Private Sub MainPage_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded

        'Load array of movies
        movie(0) = "Harry Potter"
        movie(1) = "Inglorious Basterds"
        movie(2) = "A Street Car Named Desire"
        movie(3) = "Fear and Loathing"
        movie(4) = "Life as a House"
        movie(5) = "See No Evil, Hear No Evil"
        movie(6) = "Bill & Ted's Excellent Adventure"
        movie(7) = "Teenage Mutant Ninja Turtles"
        movie(8) = "The Empire Strikes Back"
        movie(9) = "A New Hope"
        movie(10) = "Secondhand Lion's"
        movie(11) = "Gone in 60 Seconds"
        movie(12) = "American Psycho"
        movie(13) = "Superbad"
        movie(14) = "Next Friday"
        movie(15) = "Over the Top"
        movie(16) = "The Godfather"
        movie(17) = "Predator"
        movie(18) = "300"
        movie(19) = "Rambo"

        'Loads array with movie quotes
        quote(0) = "...I took a wrong turn on the way to the bathroom and found myself in a beautifully proportioned room I had never" & _
                   " seen before, containing a really rather magnificent collection of chamberpots. When I went back to investigate more" & _
                   " closely, I discovered that the room had vanished. Possibly it is only accessible at five thirty in the morning, or" & _
                   " it may only appear at the quarter moon or when the seeker has an exceptionally full bladder"
        quote(1) = "I done my share of bootleggin'. Up there, if you engage in what the federal government calls illegal activity, but what we" & _
                   " call a man just trying to earn a living for his family selling moonshine liquor, it behooves oneself to keep his wits." & _
                   " Long story short, we hear a story too good to be true Ė it ain't."
        quote(2) = "I never met a dame yet that didn't know if she was good-looking or not without being told, and there's some of them that" & _
                   " give themselves credit for more than they've got."
        quote(3) = "Few people understand the psychology of dealing with a highway traffic cop. Your normal speeder will panic and immediately" & _
                   " pull over to the side. This is wrong. It arouses contempt in the cop-heart. Make the bastard chase you. He will follow."
        quote(4) = "I think there has to be a door between where you cook and where you crap. Even in the bush - tribal people, you know, they" & _
                   " have a place for both. Probably it's like a law. God! It's probably in the Bible. It's at least a building code violation."
        quote(5) = "And then one day, my wife turned into this remarkable creature that could sit on the end of a broomstick and take off." & _
                   " She could actually achieve flight."
        quote(6) = "Strange things are afoot at the Circle K"
        quote(7) = "Yes, friends, the new turbo ginsu. Wa-hoo! It dices, it slices, and it makes French fries and three different..."
        quote(8) = "Why, you stuck up, half-witted, scruffy-looking Nerf herder."
        quote(9) = "Hokey religions and ancient weapons are no match for a good blaster at your side, kid."
        quote(10) = "I've fought in two world wars, and countless smaller ones on three continents. Iíve led thousands of men into battle with" & _
                    " everything from horses and swords to artillery and tanks. Iíve seen the headwaters of the Nile and tribes of natives no" & _
                    " white men had ever seen before. Iíve won and lost a dozen fortunes, killed many men, and loved only one woman with a" & _
                    " passion a flea like you could never begin to understand. Thatís who I am."
        quote(11) = "I just stole 50 cars for you in one night! All right? I'm a little tired. I'm a little wired! And I think I deserve a little appreciation."
        quote(12) = "Look at that subtle off-white coloring; the tasteful thickness of it..oh my God, it even has a watermark."
        quote(13) = "You know when you hear girls say 'Ah man, I was so s**t-faced last night, I shouldn't of slept with that guy?' We could be that mistake!"
        quote(14) = "She knows when all the bootleg snacks come out. grrr grrr.. cupcake got a new twinkie comin out next month... grr grrr..." & _
                    " its a bad motha f*cka.... grr grrr... when u bite into it cream shoots into ur mouth... the glitter"
        quote(15) = "I drive trucks, break arms, and arm wrestle. It's what I love to do, it's what I do best. "
        quote(16) = "Good. Someday, and that day may never come, I'll call upon you to do a service for me. But until that day Ė accept this justice as a gift on my daughter's wedding day."
        quote(17) = "Bunch of slack-jawed fa**ots around here. This stuff will make you a god da*ned sexual Tyrannosaurus, just like me."
        quote(18) = "Wow. That is generous. But you see, there is a problem. After slaughtering so many of your men today, I've got an awful" & _
                    " cramp in my leg and thus kneeling will be difficult."
        quote(19) = "They drew first blood, not me."

        'Loads first random quote when program starts
        textBlock.Text = quote(0)

        'Load 4 answers from movie array
        rb1.Content = movie(0)
        rb2.Content = movie(GenerateRandom)
        rb3.Content = movie(GenerateRandom)
        rb4.Content = movie(GenerateRandom)

    End Sub

    'Function to get a new random # between 1 and 20
    Function GenerateRandom() As Decimal
        newRandomNumber = rndRandom.Next(20)
        'Return new random #
        Return newRandomNumber
    End Function


    Private Sub rb1_Checked(sender As Object, e As System.Windows.RoutedEventArgs) Handles rb1.Checked
        If String.Equals(rb4.Content, movie(newRandomNumber)) Then
            textBlock.Text = "WIN"
        Else
            textBlock.Text = "LOSE"
        End If

        If String.Equals(rb4.Content, movie(newRandomNumber)) Then
            numberCorrect = numberCorrect + 1
        Else
            numberIncorrect = numberIncorrect + 1
        End If

        'Output info to interface
        numbercorrectLabel.Text = numberCorrect
        numberIncorrectLabel.Text = numberIncorrect
        guessPercentageLabel.Text = GetPercentage(numberCorrect, numberIncorrect)
        totalAnswered = numberCorrect + numberIncorrect

    End Sub

    Private Sub rb2_Checked(sender As Object, e As System.Windows.RoutedEventArgs) Handles rb2.Checked
        If String.Equals(rb3.Content, movie(newRandomNumber)) Then
            textBlock.Text = "WIN"
        Else
            textBlock.Text = "LOSE"
        End If
    End Sub

    Private Sub rb3_Checked(sender As Object, e As System.Windows.RoutedEventArgs) Handles rb3.Checked
        If String.Equals(rb2.Content, movie(newRandomNumber)) Then
            textBlock.Text = "WIN"
        Else
            textBlock.Text = "LOSE"
        End If
    End Sub

    Private Sub rb4_Checked(sender As Object, e As System.Windows.RoutedEventArgs) Handles rb4.Checked
        If String.Equals(rb1.Content, movie(newRandomNumber)) Then
            textBlock.Text = "WIN"
        Else
            textBlock.Text = "LOSE"
        End If
    End Sub


    'Function to determine percentage right/wrong
    Function GetPercentage(ByVal numberCorrect, ByVal numberIncorrect)
        'Variables
        Dim totalAnswered As Decimal
        Dim quoteWorth As Decimal
        Dim percentage As Decimal
        'calculations
        totalAnswered = numberCorrect + numberIncorrect
        quoteWorth = 100 / totalAnswered
        percentage = quoteWorth * numberCorrect
        'Return answer
        Return percentage
    End Function
End Class



Is This A Good Question/Topic? 0
  • +

Page 1 of 1