Results 1 to 6 of 6

Thread: .net windows frameworks

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    2

    Question .net windows frameworks

    Am trying to develop a application that either Sum or gives Product of numbers 1 to 20. It outputs results into lstoutput. Using 2 radio buttons. 1 for SUM, 1 for PRODUCT. in a textbox you list a number 1 to 20, click calculate. from there, depending on which radio button selected, it will give results in a lstoutput listbox below. Question selecting a setting controls for radio buttons, is there a selection in property window that i sent for each radio button so that i do not need to add code in the form for either SUM or PRODUCT?

    Name:  Screenshot_2021-04-03 CIS200 Sum Product no subs - Sum_Product_For_Loops_no_subs pdf.jpg
Views: 236
Size:  18.0 KB

  2. #2

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    2

    Re: .net windows frameworks

    This is my first time using VB Forums. please be patient if i post something incorrect. hints and guidance are always welcome

  3. #3
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,138

    Re: .net windows frameworks

    Are you asking if there is a shortcut way to do this calculation by using some sort of built-in properties of a radio button? If so, the answer is no.

    Presumably, this homework assignment has been assigned in conjunction with learning about using loops, so that's where you'll want to start.

    Good luck.

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

    Re: .net windows frameworks

    Quote Originally Posted by BHSully65 View Post
    is there a selection in property window that i sent for each radio button so that i do not need to add code in the form for either SUM or PRODUCT?
    Even if there was, you would almost certainly not get any marks for that because the whole point of the assignment is to write that code. Beginner assignments often expect you to do things in ways that you never would in a real application because they are trying to teach you something specific about the fundamentals of programming. In this case, you could use Enumerable.Range().Sum() to calculate the sum but that's not the point of the assignment so you'd justifiably get no marks for doing so.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: .net windows frameworks

    Also, the title you wrote has not connection at all to the question you asked. Try to summarise the topic of the question in the title.

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,479

    Re: .net windows frameworks

    I'd recommend adding a class for your calculations...

    Code:
    Public Class calc
    
        Public Shared Function getSum(n as integer) as Integer
            Dim result as integer = 0
            ' put your loop here
    
            Return result
       End Function
    
        Public Shared Function getProduct(n as integer) as Integer
            Dim result as integer = 0
            ' put your loop here
    
            Return result
       End Function
    
    End Class
    Then in your Button_Click

    Code:
    Public Sub Button1_Click(sender as Object, e as EventArgs) Handles Button1.Click
        yourLabel.Text = if(RadioButton1.Checked, "The sum of the numbers 1 to " & number & " is " & calc.getSum(number), _
                                                                       "The product of the numbers 1 to " & number & " is " & calc.getProduct(number))
    End Sub

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