TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sharmila k
NA
62
51.6k
how to display random number in vb.net c# coding?
Aug 24 2012 4:12 AM
Hi friend,
I want to display random number based customer Id.
I got the result random number but, i want result as that random number as customer Id.
This is My Coding
-------------------------
Class file coding
----------------
public int LuckyNo()
{
cmd = new SqlCommand("select count(CustomerId) from tbl_Card where LuckyPerson='1'", con);
id = Convert.ToString(cmd.ExecuteScalar());
if (id == "")
{
eid = 0;
}
else
{
eid = Convert.ToInt16(id);
}
return eid;
}
Form Load Coding
--------------------------
lblRandamNo.Text = Convert.ToString(obj.LuckyNo());
NoCustomer = Convert.ToInt32(lblRandamNo.Text);
Button Coding
--------------------
obj.MyReader("select CustomerId from tbl_Card where LuckyPerson='1'");
while (obj.dr.Read())
{
lblResult.Text = obj.dr["CustomerId"].ToString();
}
obj.dr.Close();
Id = Convert.ToInt32(lblResult.Text);
//-----------Randam Number------------//
Random rand = new Random((int)DateTime.Now.Ticks);
int numIterations = 0;
numIterations = rand.Next(NoCustomer);
txtLuckyNo.Text = Convert.ToString(numIterations);
Reply
Answers (
5
)
how to print image using print dialog controls in fixed position on form?
dynamic stored procedure and bind result into asp.net gridview using passing parameters