Im trying to write a program which simulates ten coin tosses and returns the results to the user .can anyone help please!!

Imports System.IO
Imports Microsoft.VisualBasic.ControlChars

Public Class Form1
    'write a program that simulates 10ncoin tosses using Random Number generator + Returns the results to the user.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    End Sub

    Function RandomNumber(ByVal Lowerbound As Long, ByVal Upperbound As Long)
        Randomize(3)
        RandomNumber = Int(Rnd() * Upperbound) + Lowerbound
        If RandomNumber = 0 Or 2 Then
            TextBox1.AppendText("H")
        ElseIf RandomNumber = 1 Or 3 Then
            TextBox1.AppendText("T")
        End If
    End Function

End Class

What's your problem? It's not polite to make us guess.

okay I went about it a different way but the counter I used is continually coming up with 10 for heads and 0 for tails. can anyone see whats wrong with the code??

Imports System.IO
Imports Microsoft.VisualBasic.ControlChars
Public Class Form1
    
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim count_1 As Integer
        Dim count_H As Integer
        Dim count_T As Integer

        count_1 = 0
        count_H = 0
        count_T = 0
        Do While count_1 <= 9

            Randomize()
            Dim RandomNumber As Integer = CInt(Int((10 * Rnd()) + 1))
            If RandomNumber = "1" Or "2" Or "3" Or "4" Or "5" Then
                count_H = count_H + 1
            ElseIf RandomNumber = "6" Or "7" Or "8" Or "9" Or "10" Then
                count_T = count_T + 1
            End If
            count_1 = count_1 + 1
        Loop

        TextBox1.Text = count_H
        TextBox2.Text = count_T

    End Sub



End Class

Got it working!

Imports System.IO
Imports Microsoft.VisualBasic.ControlChars
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim count_1 As Integer
        Dim count_H As Integer
        Dim count_T As Integer

        count_1 = 0
        count_H = 0
        count_T = 0
        Do While count_1 <= 9

            Randomize()
            Dim RandomNumber As Integer = CInt(Int((2 * Rnd()) + 1))
            If RandomNumber = "1" Then
                count_H = count_H + 1
            ElseIf RandomNumber = "2" Then
                count_T = count_T + 1
            End If
            count_1 = count_1 + 1
        Loop

        TextBox1.Text = count_H
        TextBox2.Text = count_T

    End Sub



End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.