الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

محتاجه شرح ل Structure ..

بدأه مــلآك في 18 أبريل 2010 · 2 رد · 664 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله وبركاته ..

مساء الورد ..

كيفكم .. إن شاء الله تماام ..

محتاجه شرح لـ Structure بشكل مفصل وكيف اقدر اتعامل معاها لاني سويت برنامج وماضبطت معاي وماني عارفه فين الخلل .

البرنامج مكون من فورمين الفورم الأول يحتوي على اسم المستخدم وكلمه المرور

( بدون ما استخدم قاعدة بيانات ) وشرط اني استخدم الـ Module

الـ Module1 يحتوي على البيانات التالية ..


Dim Name As String
Dim Password As Integer
End Structure

Public Scount As Integer = 20
Public Slength As Single = 10
Public User(Scount) As Account

Public Sub Fill_data()
User(0).Name = "ahmad"
User(0).Password = "00000"


User(1).Name = "salem"
User(1).Password = "11111"


User(2).Name = "yaser"
User(2).Password = "22222"


End Sub
Public Structure Account

الفورم الأول مكون من اثنين TextBox ( واحد تبع اسم المستخدم والثاني تبع كلمه المرور ) و Button

السؤال كيف ابرمج الـ Button بحيث انو لو دخلنا اسم المستخدم وكلمه المرور بناء على الاسماء الموجوده في Structure Account ينقلنا في الفورم الثاني ولو غلط يطلع لنا رساله


Me.Hide()
Form2.Show()
Else
MsgBox("User name and password wrong!")
End If
If TextBox1.Text = User(Scount).Name And TextBox2.Text = User(Scount).Password Then

ياليت تساعدوني واكون شاكره وممتنه لكم =)

تحياتي

#2

أختى الكريمه هذا كود به بعض التعديلات على الكود الخاص بك ب VB و C#

والتطبيقات عليهما فى المرفقات

[VB]

Public Class LoginForm1

    Public Structure Account
        Public Name As String
        Public Password As String
    End Structure

    Public Shared Scount As Integer = 20
    Public Slength As Single = 10
    Public User As Account() = New Account(Scount) {}
    Public Function Compar(ByVal param1 As String, ByVal param2 As String) As Boolean
        User(0).Name = "ahmad"
        User(0).Password = "00000"


        User(1).Name = "salem"
        User(1).Password = "11111"


        User(2).Name = "yaser"
        User(2).Password = "22222"

        User(3).Name = "a"
        User(3).Password = "a"


        While (User(Scount).Name = param1 And User(Scount).Password = param2)
            Scount += 1
        End While
        Return True
    End Function


    Private Sub ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click

        If Compar(UsernameTextBox.Text, PasswordTextBox.Text) Then
            'Me.Hide()
            Form1.Show()
        Else
            MessageBox.Show("Sorry! Wrong User Name or Password ")
        End If
    End Sub


    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click

    End Sub

End Class

=============================================================================================

[C#]

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 LOGIN
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public struct Account
        {
            public string Name;
            public string Password;
        }

        public static int Scount = 20;
        public float Slength = 10;
        public Account[] User = new Account[Scount + 1];

        public bool Compar(string param1, string param2)
        {
            User[0].Name = "ahmad";
            User[0].Password = "00000";


            User[1].Name = "salem";
            User[1].Password = "11111";


            User[2].Name = "yaser";
            User[2].Password = "22222";

            User[3].Name = "a";
            User[3].Password = "a";


            while ((User[Scount].Name == param1 & User[Scount].Password == param2))
                Scount++;
            return true;
        }


        private void OK_Click(object sender, EventArgs e)
        {
            Form2 n = new Form2();

            if (Compar(UsernameTextBox.Text, PasswordTextBox.Text))
            {
                //this.Hide();
                n.Show();
            }
            else
            {
                MessageBox.Show("Sorry! Wrong User Name or Password ");
            }
        }
    }
}

LOGIN-C#.zip

LOGIN-VB.zip

 وممّا زادنـــي شرفــاً وتيهــاً   **  وكدت بأخمصي أطأ الثريّا

دخولي تحت قولك يا عبادي  **   وأن صيّرت أحمد لي نبيّـاً

#3

amr.alsaidy

يسلموووووو والله ما قصرت

الله يوفقك ويسعدك ويحقق لك امانيك

وفي ميزان حسناتك

احتراماتي

مواضيع مشابهة