Visual Basic Birbirinden Farklı Random Sayı Üretme
Visual Basic programı gelişim aşamasında zaman zaman karşımıza visual basic birbirinden farklı random sayı üretme olup olmadığı nasıl yapılır sorusu çıkıyor.
Bu kodlar ile birlikte birbirinden farklı random sayı üretme hesabını kolayca yapabileceksiniz.
Visual Basic Birbirinden Farklı Random Sayı Üretme
Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click Button1.Text = Int(Rnd(1) * (9) + 1) Button2.Text = Int(Rnd(1) * (9) + 1) If Button2.Text = Button1.Text Then Do Until Button1.Text <> Button2.Text Button2.Text = Int(Rnd(1) * (9) + 1) Loop End If Button3.Text = Int(Rnd(1) * (9) + 1) If Button3.Text = Button1.Text Or Button3.Text = Button2.Text Then Do Until Button3.Text <> Button2.Text And Button3.Text <> Button1.Text Button3.Text = Int(Rnd(1) * (9) + 1) Loop End If Button4.Text = Int(Rnd(1) * (9) + 1) If Button4.Text = Button1.Text Or Button4.Text = Button2.Text Or Button4.Text = Button3.Text Then Do Until Button4.Text <> Button1.Text And Button4.Text <> Button2.Text And Button4.Text <> Button3.Text Button4.Text = Int(Rnd(1) * (9) + 1) Loop End If Button5.Text = Int(Rnd(1) * (9) + 1) If Button5.Text = Button1.Text Or Button5.Text = Button2.Text Or Button5.Text = Button3.Text Or Button5.Text = Button4.Text Then Do Until Button5.Text <> Button1.Text And Button5.Text <> Button2.Text And Button5.Text <> Button3.Text And Button5.Text <> Button4.Text Button5.Text = Int(Rnd(1) * (9) + 1) Loop End If Button6.Text = Int(Rnd(1) * (9) + 1) If Button6.Text = Button1.Text Or Button6.Text = Button2.Text Or Button6.Text = Button3.Text Or Button6.Text = Button4.Text Or Button6.Text = Button5.Text Then Do Until Button6.Text <> Button1.Text And Button6.Text <> Button2.Text And Button6.Text <> Button3.Text And Button6.Text <> Button4.Text And Button6.Text <> Button5.Text Button6.Text = Int(Rnd(1) * (9) + 1) Loop End If Button7.Text = Int(Rnd(1) * (9) + 1) If Button7.Text = Button1.Text Or Button7.Text = Button2.Text Or Button7.Text = Button3.Text Or Button7.Text = Button4.Text Or Button7.Text = Button5.Text Or Button7.Text = Button6.Text Then Do Until Button7.Text <> Button1.Text And Button7.Text <> Button2.Text And Button7.Text <> Button3.Text And Button7.Text <> Button4.Text And Button7.Text <> Button5.Text And Button7.Text <> Button6.Text Button7.Text = Int(Rnd(1) * (9) + 1) Loop End If Button8.Text = Int(Rnd(1) * (9) + 1) If Button8.Text = Button1.Text Or Button8.Text = Button2.Text Or Button8.Text = Button3.Text Or Button8.Text = Button4.Text Or Button8.Text = Button5.Text Or Button8.Text = Button6.Text Or Button8.Text = Button7.Text Then Do Until Button8.Text <> Button1.Text And Button8.Text <> Button2.Text And Button8.Text <> Button3.Text And Button8.Text <> Button4.Text And Button8.Text <> Button5.Text And Button8.Text <> Button6.Text And Button8.Text <> Button7.Text Button8.Text = Int(Rnd(1) * (9) + 1) Loop End If Button9.Text = Int(Rnd(1) * (9) + 1) If Button9.Text = Button1.Text Or Button9.Text = Button2.Text Or Button9.Text = Button3.Text Or Button9.Text = Button4.Text Or Button9.Text = Button5.Text Or Button9.Text = Button6.Text Or Button9.Text = Button7.Text Or Button9.Text = Button8.Text Then Do Until Button9.Text <> Button1.Text And Button9.Text <> Button2.Text And Button9.Text <> Button3.Text And Button9.Text <> Button4.Text And Button9.Text <> Button5.Text And Button9.Text <> Button6.Text And Button9.Text <> Button7.Text And Button9.Text <> Button8.Text Button9.Text = Int(Rnd(1) * (9) + 1) Loop End If End Sub End Class
Sizlerde kendi yazdığınız programları, istek ve sorularınızı bizlere iletişim kısmından iletebilirsiniz.
Visual Basic ile ilgili kavramlara ek olarak, Visual Basic öğrenimini teşvik etmek için karar verme ve döngü kontrolleri dahil olmak üzere bazı örnekler ve örnek uygulamalar vardır. Kodlarda herhangi bir problem olduğunda lütfen yorum kısmından iletişime geçiniz.
Örnek Programlar
VİSUAL BASİC KAÇ GÜNDÜR YAŞADIĞIMIZI BULAN PROGRAM
3 ADET SAYIDAN EN BÜYÜĞÜNÜ VE EN KÜÇÜĞÜNÜ BULMA VİSUAL BASİC