نمایش نتایج 1 تا 3 از 3

نام تاپیک: تبدیل vb6 به C#‎

  1. #1
    کاربر دائمی آواتار bahar_engineer
    تاریخ عضویت
    دی 1387
    محل زندگی
    تهران
    پست
    657

    Cool تبدیل vb6 به C#‎

    سلام
    من یه کد پازل دارم ... یک تصویر که به چندین قسمت مساوی تقسیم شده و تصاویر به هم ریخته را مرتب می کنه
    این کد که به زبان ویژوال بیسیک 6 هست رو می خوام convert کنم به سی شارپ ...
    من توی 2005 کار می کنم

    یه convertor پیدا کردم اما حلقه ها و بعضی دیگه از دستورات رو درست تبدیل نکرده

    ممکنه کمک کنید


    Option Explicit

    Dim second As Integer
    Dim a As Boolean
    Dim b As Long
    Dim g As String

    Private Sub cmdcorrect_Click()

    Dim i As Integer
    Dim strfilename As String

    a = False

    For i = 0 To 8

    strfilename = App.Path + "\" + Trim(Str(i)) + ".bmp"
    img(i).Picture = LoadPicture(strfilename)
    img(i).Tag = i

    Next

    second = 0

    cmdplay.Enabled = True
    cmdcorrect.Enabled = False

    End Sub

    Private Sub cmdplay_Click()

    Dim z As Integer
    Dim z2 As Integer
    Dim i As Integer

    Call cmdcorrect_Click

    For i = 0 To 8

    Randomize
    z = 8 * Rnd
    z2 = 8 * Rnd
    imgtemp.Picture = img(z).Picture
    img(z).Picture = img(z2).Picture
    img(z2).Picture = imgtemp.Picture
    imgtemp.Tag = img(z).Tag
    img(z).Tag = img(z2).Tag
    img(z2).Tag = imgtemp.Tag

    Next

    a = True
    b = Timer

    Timer1.Enabled = True
    cmdcorrect.Enabled = False
    img(0).Enabled = True
    img(1).Enabled = True
    img(2).Enabled = True
    img(3).Enabled = True
    img(4).Enabled = True
    img(5).Enabled = True
    img(6).Enabled = True
    img(7).Enabled = True
    img(8).Enabled = True

    End Sub

    Private Sub Command1_Click()

    End

    End Sub

    Private Sub Form_Activate()

    'Skin1.ApplySkin hWnd

    End Sub

    Private Sub Form_Load()

    cmdplay.Enabled = False
    img(0).Enabled = False
    img(1).Enabled = False
    img(2).Enabled = False
    img(3).Enabled = False
    img(4).Enabled = False
    img(5).Enabled = False
    img(6).Enabled = False
    img(7).Enabled = False
    img(8).Enabled = False

    End Sub

    Private Sub img_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)

    Dim strtime As String

    If a = False Then

    Exit Sub

    End If

    imgtemp.Picture = img(Index).Picture
    img(Index).Picture = Source.Picture
    Source.Picture = imgtemp.Picture

    imgtemp.Tag = img(Index).Tag
    img(Index).Tag = Source.Tag
    Source.Tag = imgtemp.Tag

    If CheckCorrect = True Then

    strtime = Str(Int(Timer - b))
    MsgBox ("ÒãÇä ӁÑí ÔÏå : " + strtime + " ËÇäíå "), vbInformation, "ÞåÑãÇä"

    cmdcorrect.Enabled = True
    Command1.Enabled = True

    a = False
    img(0).Enabled = False
    img(1).Enabled = False
    img(2).Enabled = False
    img(3).Enabled = False
    img(4).Enabled = False
    img(5).Enabled = False
    img(6).Enabled = False
    img(7).Enabled = False
    img(8).Enabled = False

    End If
    End Sub

    Private Function CheckCorrect() As Boolean

    Dim i As Integer

    For i = 0 To 8

    If img(i).Tag <> i Then

    CheckCorrect = False
    Exit Function

    End If

    Next

    CheckCorrect = True
    second = 0

    End Function

    Private Sub Timer1_Timer()

    If a = True Then

    second = second + 1
    Label1.Caption = second

    If second = 15 Then Timer1.Enabled = False
    If Timer1.Enabled = False Then

    MsgBox ("æÞÊ ÔãÇ ÊãÇã ÔÏ"), vbCritical, "ÇÊãÇã ÒãÇä"
    cmdplay.Enabled = False
    Command1.Enabled = True
    cmdcorrect.Enabled = True
    img(0).Enabled = False
    img(1).Enabled = False
    img(2).Enabled = False
    img(3).Enabled = False
    img(4).Enabled = False
    img(5).Enabled = False
    img(6).Enabled = False
    img(7).Enabled = False
    img(8).Enabled = False

    End If
    End If
    End Sub




    اینم تبدیل شده به سی شارپ هست اما مشکل داره

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;

    namespace ProjectName
    {
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.ACTIVESKINLibCtl.Skin Skin1;
    private System.Windows.Forms.Timer Timer1;
    private System.Windows.Forms.Button cmdcorrect;
    private System.Windows.Forms.Button cmdplay;
    private System.Windows.Forms.Button Command1;
    private System.Windows.Forms.Label Label1;
    private System.Windows.Forms.PictureBox imgtemp;
    private System.Windows.Forms.PictureBox img8;
    private System.Windows.Forms.PictureBox img7;
    private System.Windows.Forms.PictureBox img6;
    private System.Windows.Forms.PictureBox img5;
    private System.Windows.Forms.PictureBox img4;
    private System.Windows.Forms.PictureBox img3;
    private System.Windows.Forms.PictureBox img2;
    private System.Windows.Forms.PictureBox img1;
    private System.Windows.Forms.PictureBox img0;
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null;

    public Form1()
    {
    // Required for Windows Form Designer support
    InitializeComponent();

    // TODO: Add any constructor code after InitializeComponent call
    }
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null)
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    }
    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    this.Skin1 = new System.Windows.Forms.ACTIVESKINLibCtl.Skin();
    this.Timer1 = new System.Windows.Forms.Timer();
    this.cmdcorrect = new System.Windows.Forms.Button();
    this.cmdplay = new System.Windows.Forms.Button();
    this.Command1 = new System.Windows.Forms.Button();
    this.Label1 = new System.Windows.Forms.Label();
    this.imgtemp = new System.Windows.Forms.PictureBox();
    this.img8 = new System.Windows.Forms.PictureBox();
    this.img7 = new System.Windows.Forms.PictureBox();
    this.img6 = new System.Windows.Forms.PictureBox();
    this.img5 = new System.Windows.Forms.PictureBox();
    this.img4 = new System.Windows.Forms.PictureBox();
    this.img3 = new System.Windows.Forms.PictureBox();
    this.img2 = new System.Windows.Forms.PictureBox();
    this.img1 = new System.Windows.Forms.PictureBox();
    this.img0 = new System.Windows.Forms.PictureBox();
    this.SuspendLayout();
    //
    // Skin1
    //
    this.Skin1.Name = "Skin1";
    this.Skin1.Location = new System.Drawing.Point(264, 128);
    // this.Skin1.OleObjectBlob = "Form1.frx":0000;
    //
    // Timer1
    //
    this.Timer1.Enabled = false;
    this.Timer1.Interval = 1000;
    //
    // cmdcorrect
    //
    this.cmdcorrect.Name = "cmdcorrect";
    this.cmdcorrect.Text = " ";
    this.cmdcorrect.Font = new System.Drawing.Font("B Traffic",9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(178)));;
    this.cmdcorrect.Size = new System.Drawing.Size(81, 33);
    this.cmdcorrect.Location = new System.Drawing.Point(8, 208);
    this.cmdcorrect.TabIndex = 2;
    //
    // cmdplay
    //
    this.cmdplay.Name = "cmdplay";
    this.cmdplay.Text = " ";
    this.cmdplay.DialogResult = System.Windows.Forms.DialogResult.OK;
    this.cmdplay.Font = new System.Drawing.Font("B Traffic",9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(178)));;
    this.cmdplay.Size = new System.Drawing.Size(81, 33);
    this.cmdplay.Location = new System.Drawing.Point(168, 208);
    this.cmdplay.TabIndex = 1;
    //
    // Command1
    //
    this.Command1.Name = "Command1";
    this.Command1.Text = "";
    this.Command1.Font = new System.Drawing.Font("B Traffic",9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(178)));;
    this.Command1.Size = new System.Drawing.Size(81, 33);
    this.Command1.Location = new System.Drawing.Point(88, 208);
    this.Command1.TabIndex = 0;
    //
    // Label1
    //
    this.Label1.Name = "Label1";
    this.Label1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
    this.Label1.AutoSize = true;
    this.Label1.Text = "00";
    this.Label1.Size = new System.Drawing.Size(13, 13);
    this.Label1.Location = new System.Drawing.Point(264, 176);
    this.Label1.TabIndex = 3;
    this.Label1.Visible = false;
    //
    // imgtemp
    //
    this.imgtemp.Name = "imgtemp";
    this.imgtemp.Size = new System.Drawing.Size(81, 65);
    this.imgtemp.Location = new System.Drawing.Point(264, 8);
    // this.imgtemp.Stretch = -1;
    this.imgtemp.Visible = false;
    //
    // img8
    //
    this.img8.Name = "img8";
    this.img8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    // this.img8.DragMode = 1;
    this.img8.Size = new System.Drawing.Size(81, 65);
    this.img8.Location = new System.Drawing.Point(168, 136);
    // this.img8.Stretch = -1;
    //
    // img7
    //
    this.img7.Name = "img7";
    this.img7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    // this.img7.DragMode = 1;
    this.img7.Size = new System.Drawing.Size(81, 65);
    this.img7.Location = new System.Drawing.Point(88, 136);
    // this.img7.Stretch = -1;
    //
    // img6
    //
    this.img6.Name = "img6";
    this.img6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    // this.img6.DragMode = 1;
    this.img6.Size = new System.Drawing.Size(81, 65);
    this.img6.Location = new System.Drawing.Point(8, 136);
    // this.img6.Stretch = -1;
    //
    // img5
    //
    this.img5.Name = "img5";
    this.img5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    // this.img5.DragMode = 1;
    this.img5.Size = new System.Drawing.Size(81, 65);
    this.img5.Location = new System.Drawing.Point(168, 72);
    // this.img5.Stretch = -1;
    //
    // img4
    //
    this.img4.Name = "img4";
    this.img4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    // this.img4.DragMode = 1;
    this.img4.Size = new System.Drawing.Size(81, 65);
    this.img4.Location = new System.Drawing.Point(88, 72);
    // this.img4.Stretch = -1;
    //
    // img3
    //
    this.img3.Name = "img3";
    this.img3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    // this.img3.DragMode = 1;
    this.img3.Size = new System.Drawing.Size(81, 65);
    this.img3.Location = new System.Drawing.Point(8, 72);
    // this.img3.Stretch = -1;
    //
    // img2
    //
    this.img2.Name = "img2";
    this.img2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    // this.img2.DragMode = 1;
    this.img2.Size = new System.Drawing.Size(81, 65);
    this.img2.Location = new System.Drawing.Point(168, 8);
    // this.img2.Stretch = -1;
    //
    // img1
    //
    this.img1.Name = "img1";
    this.img1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    // this.img1.DragMode = 1;
    this.img1.Size = new System.Drawing.Size(81, 65);
    this.img1.Location = new System.Drawing.Point(88, 8);
    // this.img1.Stretch = -1;
    //
    // img0
    //
    this.img0.Name = "img0";
    this.img0.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    // this.img0.DragMode = 1;
    this.img0.Size = new System.Drawing.Size(81, 65);
    this.img0.Location = new System.Drawing.Point(8, 8);
    // this.img0.Stretch = -1;
    //
    // Form1
    //
    this.Controls.AddRange(new System.Windows.Forms.Control[]
    {
    this.Skin1,
    this.cmdcorrect,
    this.cmdplay,
    this.Command1,
    this.Label1,
    this.imgtemp,
    this.img8,
    this.img7,
    this.img6,
    this.img5,
    this.img4,
    this.img3,
    this.img2,
    this.img1,
    this.img0
    });
    this.Name = "Form1";
    this.BackColor = System.Drawing.Color.FromArgb(-4144897);
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    this.ClientSize = new System.Drawing.Size(257, 249);
    this.MaximizeBox = false;
    this.MinimizeBox = false;
    this.ShowInTaskbar = false;
    this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScree n;
    this.ResumeLayout(false);
    }
    #endregion

    private short second;
    private bool a;
    private int b;
    private string g;
    private short i;
    private string strfilename;
    private short z;
    private short z2;
    private short i;
    private string strtime;
    private short i;

    private void cmdcorrect_Click()
    {


    a = false;

    For i = 0 To 8;

    strfilename = App.Path + "\" + Trim(Str(i)) + ".bmp";
    img(i).Picture = LoadPicture(strfilename);
    img(i).Tag = i;

    Next;

    second = 0;

    cmdplay.Enabled = true;
    cmdcorrect.Enabled = false;

    }
    private void cmdplay_Click()
    {


    Call cmdcorrect_Click;

    For i = 0 To 8;

    Randomize;
    z = 8 * Rnd;
    z2 = 8 * Rnd;
    imgtemp.Picture = img(z).Picture;
    img(z).Picture = img(z2).Picture;
    img(z2).Picture = imgtemp.Picture;
    imgtemp.Tag = img(z).Tag;
    img(z).Tag = img(z2).Tag;
    img(z2).Tag = imgtemp.Tag;

    Next;

    a = true;
    b = Timer;

    Timer1.Enabled = true;
    cmdcorrect.Enabled = false;
    img(0).Enabled = true;
    img(1).Enabled = true;
    img(2).Enabled = true;
    img(3).Enabled = true;
    img(4).Enabled = true;
    img(5).Enabled = true;
    img(6).Enabled = true;
    img(7).Enabled = true;
    img(8).Enabled = true;

    }
    private void Command1_Click()
    {

    }
    private void Form_Activate()
    {

    Skin1.ApplySkin hWnd;

    }
    private void Form_Load()
    {

    cmdplay.Enabled = false;
    img(0).Enabled = false;
    img(1).Enabled = false;
    img(2).Enabled = false;
    img(3).Enabled = false;
    img(4).Enabled = false;
    img(5).Enabled = false;
    img(6).Enabled = false;
    img(7).Enabled = false;
    img(8).Enabled = false;

    }
    private void img_DragDrop {


    if ( a = false )
    {;

    Exit Sub;

    };

    imgtemp.Picture = img(Index).Picture;
    img(Index).Picture = Source.Picture;
    Source.Picture = imgtemp.Picture;

    imgtemp.Tag = img(Index).Tag;
    img(Index).Tag = Source.Tag;
    Source.Tag = imgtemp.Tag;

    if ( CheckCorrect = true )
    {;

    strtime = Str(Int(Timer - b));
    MsgBox (" Ӂ : " + strtime + " "), vbInformation, "";

    cmdcorrect.Enabled = true;
    Command1.Enabled = true;

    a = false;
    img(0).Enabled = false;
    img(1).Enabled = false;
    img(2).Enabled = false;
    img(3).Enabled = false;
    img(4).Enabled = false;
    img(5).Enabled = false;
    img(6).Enabled = false;
    img(7).Enabled = false;
    img(8).Enabled = false;

    };
    }
    private As CheckCorrect()
    {


    For i = 0 To 8;

    if ( img(i).Tag <> i )
    {;

    CheckCorrect = false;
    Exit Function;

    };

    Next;

    CheckCorrect = true;
    second = 0;

    }
    private void Timer1_Timer()
    {

    if ( a = true )
    {;

    second = second + 1;
    Label1.Text = second;

    if ( second = 15 )
    {
    Timer1.Enabled = false;
    if ( Timer1.Enabled = false )
    {;

    MsgBox (" "), vbCritical, " ";
    cmdplay.Enabled = false;
    Command1.Enabled = true;
    cmdcorrect.Enabled = true;
    img(0).Enabled = false;
    img(1).Enabled = false;
    img(2).Enabled = false;
    img(3).Enabled = false;
    img(4).Enabled = false;
    img(5).Enabled = false;
    img(6).Enabled = false;
    img(7).Enabled = false;
    img(8).Enabled = false;

    };
    };
    }
    }
    }



  2. #2

    نقل قول: تبدیل vb6 به C#‎

    اسم کانورتو که استفاده می کنی چی هستش
    ودر ضمن من این کد رو با استفاده از # Instant c که مال شرکت tangible softwares تبدیل کردم که امیدوارم کار بکنه

    private int second;
    private bool a;
    private long b;
    private string g;

    private void cmdcorrect_Click()
    {

    int i = 0;
    string strfilename = null;

    a = false;

    for (i = 0; i <= 8; i++)
    {

    strfilename = App.Path + "\\" + System.Convert.ToString(i).ToString().Trim(' ') + ".bmp";
    img(i).Picture = LoadPicture(strfilename);
    img(i).Tag = i;

    }

    second = 0;

    cmdplay.Enabled = true;
    cmdcorrect.Enabled = false;

    }

    private void cmdplay_Click()
    {

    int z = 0;
    int z2 = 0;
    int i = 0;

    cmdcorrect_Click();

    for (i = 0; i <= 8; i++)
    {

    Randomize;
    z = 8 * Rnd;
    z2 = 8 * Rnd;
    imgtemp.Picture = img(z).Picture;
    img(z).Picture = img(z2).Picture;
    img(z2).Picture = imgtemp.Picture;
    imgtemp.Tag = img(z).Tag;
    img(z).Tag = img(z2).Tag;
    img(z2).Tag = imgtemp.Tag;

    }

    a = true;
    b = Timer;

    Timer1.Enabled = true;
    cmdcorrect.Enabled = false;
    img(0).Enabled = true;
    img(1).Enabled = true;
    img(2).Enabled = true;
    img(3).Enabled = true;
    img(4).Enabled = true;
    img(5).Enabled = true;
    img(6).Enabled = true;
    img(7).Enabled = true;
    img(8).Enabled = true;

    }

    private void Command1_Click()
    {

    System.Environment.Exit(1);

    }

    private void Form_Activate()
    {

    //Skin1.ApplySkin hWnd

    }

    private void Form_Load()
    {

    cmdplay.Enabled = false;
    img(0).Enabled = false;
    img(1).Enabled = false;
    img(2).Enabled = false;
    img(3).Enabled = false;
    img(4).Enabled = false;
    img(5).Enabled = false;
    img(6).Enabled = false;
    img(7).Enabled = false;
    img(8).Enabled = false;

    }

    private void img_DragDrop(int Index, Control Source, float X, float Y)
    {

    string strtime = null;

    if (a == false)
    {

    return;

    }

    imgtemp.Picture = img(Index).Picture;
    img(Index).Picture = Source.Picture;
    Source.Picture = imgtemp.Picture;

    imgtemp.Tag = img(Index).Tag;
    img(Index).Tag = Source.Tag;
    Source.Tag = imgtemp.Tag;

    if (CheckCorrect() == true)
    {

    strtime = System.Convert.ToString((int)Math.Floor(Timer - b)).ToString();
    MessageBox.Show("ÒãÇä ӁÑí ÔÏå : " + strtime + " ËÇäíå "), Microsoft.VisualBasic.Constants.vbInformation, "ÞåÑãÇä";

    cmdcorrect.Enabled = true;
    Command1.Enabled = true;

    a = false;
    img(0).Enabled = false;
    img(1).Enabled = false;
    img(2).Enabled = false;
    img(3).Enabled = false;
    img(4).Enabled = false;
    img(5).Enabled = false;
    img(6).Enabled = false;
    img(7).Enabled = false;
    img(8).Enabled = false;

    }
    }

    private bool CheckCorrect()
    {
    bool tempCheckCorrect = false;

    int i = 0;

    for (i = 0; i <= 8; i++)
    {

    if (img(i).Tag != i)
    {

    return false;

    }

    }

    tempCheckCorrect = true;
    second = 0;

    return tempCheckCorrect;
    }

    private void Timer1_Timer()
    {

    if (a == true)
    {

    second = second + 1;
    Label1.Caption = second;

    if (second == 15)
    {
    Timer1.Enabled = false;
    }
    if (Timer1.Enabled == false)
    {

    MessageBox.Show("æÞÊ ÔãÇ ÊãÇã ÔÏ"), Microsoft.VisualBasic.Constants.vbCritical, "ÇÊãÇã ÒãÇä";
    cmdplay.Enabled = false;
    Command1.Enabled = true;
    cmdcorrect.Enabled = true;
    img(0).Enabled = false;
    img(1).Enabled = false;
    img(2).Enabled = false;
    img(3).Enabled = false;
    img(4).Enabled = false;
    img(5).Enabled = false;
    img(6).Enabled = false;
    img(7).Enabled = false;
    img(8).Enabled = false;

    }
    }
    }

  3. #3

    نقل قول: تبدیل vb6 به C#‎

    البته از ظاهر قضیه بر میاد که کار کنه

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •