Results 1 to 4 of 4
-
4th Jul 2010, 11:06 PM #1OPლ(ಠ益ಠლ)Website's:
extremecoderz.com[c#] simple login box with logic
This little example shows how to create objects without the use of the Design view, how to position the items, how to use the items, using objective programming and making use of returned results.
Hope it helps a few on the way.
PHP Code:using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication9
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.Size = new Size(170, 200);
DrawObjects();
}
private void DrawObjects()
{
// draw some controls
TextBox uname = new TextBox();
uname.Name = "uname_tb";
uname.Location = new Point(20, 20);
uname.Size = new Size(100, 23);
this.Controls.Add(uname);
TextBox pword = new TextBox();
pword.Name = "pwd_tb";
pword.Location = new Point(20, 53);
pword.Size = new Size(100, 23);
this.Controls.Add(pword);
Button button1 = new Button();
button1.Location = new Point(20, 86);
button1.Size = new Size(100, 23);
button1.Click += new EventHandler(button_click);
button1.Text = "Login";
this.Controls.Add(button1);
Label myLabel = new Label();
myLabel.Name = "statusLabel";
myLabel.Location = new Point(20, 119);
myLabel.Text = "Ready.";
this.Controls.Add(myLabel);
}
private void button_click(object sender, EventArgs e)
{
// create some controls so we can access them.
TextBox uname = new TextBox();
TextBox pwd = new TextBox();
Label status = new Label();
// for each control in this forms controls
foreach (Control control in this.Controls)
{
if (control is TextBox)
{
if (control.Name == "uname_tb")
uname = (TextBox)control;
if (control.Name == "pwd_tb")
pwd = (TextBox)control;
}
if (control is Label)
{
if (control.Name == "statusLabel")
status = (Label)control;
}
}
// get the value of the boolean object "checkLogin"
// with these details, and store the returned output
// in a boolean form.
Boolean output = checkLogin(uname.Text, pwd.Text);
// if the result of "checkLogin"....
if (!output)
status.Text = "false";
else
status.Text = "true";
}
private bool checkLogin(string username, string password)
{
// if the username and password are correct.
if (username == "jayfella" && password == "letmein")
return true;
else return false;
}
}
}
jayfella Reviewed by jayfella on . [c#] simple login box with logic This little example shows how to create objects without the use of the Design view, how to position the items, how to use the items, using objective programming and making use of returned results. Hope it helps a few on the way. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; Rating: 5
-
5th Jul 2010, 02:14 AM #2Member
uhm, I don't understand what each lines does. So lost ....
-
5th Jul 2010, 02:48 AM #3Teh GFX Whore! ^.^
yes..this is really simple. I know this much C++ so could understand you this time
-
5th Jul 2010, 04:31 AM #4Banned
Its simple hardcoded username and passwords.. its just like entering two words and comparing them with two predefined words..
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
LOGICUBIKS - new IPhone logic game
By layla8540 in forum General DiscussionReplies: 0Last Post: 8th Sep 2011, 05:51 PM -
Cant Login My Msn :(
By -zAAz- in forum Technical Help Desk SupportReplies: 12Last Post: 22nd Apr 2011, 07:52 AM -
Can't login
By c0rrupt in forum IP.BoardReplies: 16Last Post: 17th Nov 2010, 01:47 AM
themaLeecher - leech and manage...
Version 4.94 released. Open older version (or...