Results 1 to 4 of 4

Thread: Could use some vb help on a school assignment

  1. #1

    Default Could use some vb help on a school assignment

    Because I'm just that bad at programming, I'm trying to complete the following in VB using Visual Studio. Any help would be appreciated. My last programming class ever and just really trying to get through it.

    1. Write a program to display 1000 8-character random user IDs in a text box after you click a button. Make sure the program verifies that none of the IDs are identical. Each userid should include a mixture of alphabetic characters and numbers.

    2. Write a function that will calculate the area of a sphere and will handle all types of possible errors

    Figure the 1st one should be easy enough, I've been researching and working through code trying to get it to work out.

  2. #2
    Join Date
    Jul 2009
    Posts
    4,798
    Blog Entries
    1

    Default

    Only familiar with MS Office VBA... but concepts similar enough:
    1)
    Loop 8 times
    Random 0,1
    if 0, generate a random number
    if 1, generate a random letter
    If loop run = 0, set value as above
    If loop run >0, set value = value + new value
    close loop
    if most recent value matches any previous value, return to previous loop
    if most recent value does not match any previous value, add 1 to counter, and repeat


    second one:
    How many variables are there really? just pi * 4 r^2
    So... is r positive, not 0.
    If number(r) = false then return = "Please enter a number"
    If r < 0 then return = "Please use a positive radius"
    If r = 0 then return = "No physical area"
    Return = pi * 4 * r^2

    something like that should work... syntax is all you.
    Last edited by Whirlin; 11-25-2016 at 10:53 PM.


    >forage for snapdragon stalk
    d100(Open): -251
    You stumble about in a fruitless attempt at foraging.

    1/6/2014: Setheve completes the promotion ritual and says, "Congratulations, Whirlin, for achieving Guild Master status! We trust you'll serve your guild well."
    1/11/2014: Grandmaster Alchemist
    1/14/2014: Capped, and got Loralaii killed by a GM.
    7/11/2016: Founded the Hand of the Arkati
    9/20/2016: T5 on my bow (Thanks to Isola)... Managed as far as T4 myself.

  3. #3

    Default

    Thanks Whirlin, I think I figured it out for anyone interested:

    Code:
    Public Class Form1
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
        End Sub
        Public Function makeID() As Object
            Dim r, a, q, c, b As Object
            r = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
            a = Len(r)
            q = 8
            Randomize()
            c = ""
            For intstep = 1 To q
                b = Int((a * Rnd()) + 1)
                c = c & Mid(r, b, 1)
            Next
            makeID = c
        End Function
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim a As String
            While ListBox1.Items.Count < 1001
                a = makeID()
                ListBox1.Items.Add(a)
            End While
    
        End Sub
    End Class

  4. Default

    Quote Originally Posted by Erous View Post
    Because I'm just that bad at programming, I'm trying to complete the following in VB using Visual Studio. Any help would be appreciated. My last programming class ever and just really trying to get through it.

    1. Write a program to display 1000 8-character random user IDs in a text box after you click a button. Make sure the program verifies that none of the IDs are identical. Each userid should include a mixture of alphabetic characters and numbers.

    2. Write a function that will calculate the area of a sphere and will handle all types of possible errors

    Figure the 1st one should be easy enough, I've been researching and working through code trying to get it to work out.
    I also had a visual basic course at university. This course was very interesting, so I could concentrate on only one subject and could not do other subjects, especially those that I did not love like writing papers. That's why I bought papers from the service https://cheetahpapers.com/essay/do/ and focused my attention on only one subject - the visual basic course.

Similar Threads

  1. Fixstat perfect stat assignment?
    By nocturnix in forum Game Mechanics
    Replies: 7
    Last Post: 08-12-2021, 06:18 PM
  2. Replies: 5
    Last Post: 06-08-2009, 08:02 PM
  3. Assignment of Guild Ranks
    By ElanthianSiren in forum Warrior
    Replies: 13
    Last Post: 09-11-2007, 02:56 PM
  4. School.
    By Betheny in forum Off-Topic
    Replies: 30
    Last Post: 03-04-2004, 07:58 AM

Posting Permissions

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