Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > ช่วยแปลง code จาก VB.NET เป็น C# ให้หน่อย แนะนำการแปลง VB.NET เป็น C#



 

ช่วยแปลง code จาก VB.NET เป็น C# ให้หน่อย แนะนำการแปลง VB.NET เป็น C#

 



Topic : 040674



โพสกระทู้ ( 4 )
บทความ ( 0 )



สถานะออฟไลน์




Code (VB.NET)
Dim title As TextBox = CType(e.Item.Cells(3).Control(0),TextBox)
Dim category As TextBox = CType(e.Item.Cells(4).Control(0),TextBox)

straql = "UPDATE book SET ='" & title.text & "'& category.Text & "' WHERE ID = " & DataGrid1.DataKeys.Item(e.ItemIndex)




Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-03-22 17:34:13 By : eclipse View : 3283 Reply : 5
 

 

No. 1



โพสกระทู้ ( 11,835 )
บทความ ( 10 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


http://www.developerfusion.com/tools/convert/vb-to-csharp






Date : 2010-03-22 17:39:38 By : plakrim
 


 

No. 2



โพสกระทู้ ( 4 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณสำหรับวิธีการ
Date : 2010-03-23 15:58:54 By : eclipse
 

 

No. 3

Guest


Code (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;
using System.IO;
using System.Data.SqlClient;
using System.Data.OleDb;

namespace GTHFormsApplication
{
    public partial class gthmovie : Form
    {
        

        string movType;
        string year;
        string rating;
        string selectStr;
        string strConnString = " ";
        // Data Source = ชื่อ server; Initial Catalog = ชื่อ DB;Integrated Security = การเข้ารหัสข้อมูล
        bool isTypeSelect = false;
        bool isRateSelect = false;
        bool isYesrSelect = false;

        public gthmovie()
        {
            InitializeComponent();
        }
     
        private void submitButton_Click(object sender, EventArgs e)
        {
            movType = movieTypeComboBox.Text;
            year = yearComboBox.Text;

            if (movType.Equals("Movie Type"))
            {
                isTypeSelect = false;
            }
            else
            {
                isTypeSelect = true;
            }

            if (year.Equals("Year"))
            {
                isYesrSelect = false;
            }
            else
            {
                isYesrSelect = true;
            }

            if (radioButton6.Checked)
            {
                rating = "allRate";
            }
            else if (radioButton1.Checked)
            {
                rating = "all";
                isRateSelect = true;
            }
            else if (radioButton2.Checked)
            {
                rating = "13";
                isRateSelect = true;
            }
            else if (radioButton3.Checked)
            {
                rating = "15";
                isRateSelect = true;
            }
            else if (radioButton4.Checked)
            {
                rating = "18";
                isRateSelect = true;
            }
            else if (radioButton5.Checked)
            {
                rating = "20";
                isRateSelect = true;
            }
            else
            {
                rating = "no";
                isRateSelect = false;
            }
            showDetails();
        }
      
        public void showDetails()
        {
            string tmp = null;
            if (movieTypeComboBox.Text.Equals("Movie Type") && yearComboBox.Text.Equals("Year") && rating.Equals("no"))
            {
                tmp += "\n Please select at least 1 chioce.";
            }

            if (tmp != null)
            {
                MessageBox.Show(tmp);
            }
            else
            {
                if ((movType.Equals("All Movie Type") && isYesrSelect == false && isRateSelect == false) ||
                    (isTypeSelect == false && year.Equals("All Year") && isRateSelect == false) ||
                    (isTypeSelect == false && isYesrSelect == false && radioButton6.Checked) ||
                    (movType.Equals("All Movie Type") && year.Equals("All Year") && isRateSelect == false) ||
                    (movType.Equals("All Movie Type") && isYesrSelect == false && radioButton6.Checked) ||
                    (isTypeSelect == false && year.Equals("All Year") && radioButton6.Checked) ||
                    (movType.Equals("All Movie Type") && year.Equals("All Year") && radioButton6.Checked))
                {
                    selectStr = "Select * FROM gth";
                }
                else if (movType.Equals("All Movie Type") && isYesrSelect == true && isRateSelect == true)
                {
                    selectStr = "Select * FROM gth WHERE year = '" + year + "' AND rat = '" + rating + "'";
                }
                else if (isTypeSelect == true && year.Equals("All Year") && isRateSelect == true)
                {
                    selectStr = "Select * FROM gth WHERE movie_type = '" + movType + "' AND rat = '" + rating + "'";
                }
                else if (isTypeSelect == true && isYesrSelect == true && radioButton6.Checked)
                {
                    selectStr = "Select * FROM gth WHERE movie_type = '" + movType + "' AND year = '" + year + "'";
                }
                else if ((movType.Equals("All Movie Type") && isYesrSelect == false && isRateSelect == true) || (isTypeSelect == false && year.Equals("All Year") && isRateSelect == true) || (movType.Equals("All Movie Type") && year.Equals("All Year") && isRateSelect == true))
                {
                    selectStr = "Select * FROM gth WHERE rat = '" + rating + "'";
                }
                else if ((isTypeSelect == true && year.Equals("All Year") && isRateSelect == false) || (isTypeSelect == true && isYesrSelect == false && radioButton6.Checked) || (isTypeSelect == true && year.Equals("All Year") && radioButton6.Checked))
                {
                    selectStr = "Select * FROM gth WHERE movie_type = '" + movType + "'";
                }
                else if ((movType.Equals("All Movie Type") && isYesrSelect == true && isRateSelect == false) || (isTypeSelect == false && isYesrSelect == true && radioButton6.Checked) || (movType.Equals("All Movie Type") && isYesrSelect == true && radioButton6.Checked))
                {
                    selectStr = "Select * FROM gth WHERE year = '" + year + "'";
                }
                else if (isTypeSelect == true && isYesrSelect == false && isRateSelect == false)
                {
                    selectStr = "Select * FROM gth WHERE movie_type = '" + movType + "'";
                }
                else if (isTypeSelect == false && isYesrSelect == true && isRateSelect == false)
                {
                    selectStr = "Select * FROM gth WHERE year = '" + year + "'";
                }
                else if (isTypeSelect == false && isYesrSelect == false && isRateSelect == true)
                {
                    selectStr = "Select * FROM gth WHERE rat = '" + rating + "'";
                }
                else if (isTypeSelect == true && isYesrSelect == true && isRateSelect == false)
                {
                    selectStr = "Select * FROM gth WHERE movie_type = '" + movType + "' AND year = '" + year + "'";
                }
                else if (isTypeSelect == true && isYesrSelect == false && isRateSelect == true)
                {
                    selectStr = "Select * FROM gth WHERE movie_type = '" + movType + "' AND rat = '" + rating + "'";
                }
                else if (isTypeSelect == false && isYesrSelect == true && isRateSelect == true)
                {
                    selectStr = "Select * FROM gth WHERE year = '" + year + "' AND rat = '" + rating + "'";
                }
                else if (isTypeSelect == true && isYesrSelect == true && isRateSelect == true)
                {
                    selectStr = "Select * FROM gth WHERE movie_type = '" + movType + "' AND year = '" + year + "' AND rat = '" + rating + "'";
                }
                else
                {
                    selectStr = "SELECT * FROM gth";
                }

                try
                {
                  SqlDataAdapter sqlAdap = new SqlDataAdapter(selectStr, strConnString);
                    
                    SqlCommandBuilder sqlBuild = new SqlCommandBuilder(sqlAdap);
                    
                    DataTable t = new DataTable();
                    
                    sqlAdap.Fill(t);
                    
                    dataGridView1.DataSource = t;
                  
                    dataGridView1.Visible = true;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }

            }
        }

        private void yearComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
        
        private void restButton_Click(object sender, EventArgs e)
        {
            dataGridView1.Visible = false;
            yearComboBox.Text = "Year";
            movieTypeComboBox.Text = "Movie Type";
            radioButton1.Checked = false;
            radioButton2.Checked = false;
            radioButton3.Checked = false;
            radioButton4.Checked = false;
            radioButton5.Checked = false;
            radioButton6.Checked = false;
            movType = "";
            year = "";
            rating = "";
            selectStr = "";
            isTypeSelect = false;
            isRateSelect = false;
            isYesrSelect = false;
        }

        }
    }


ช่วยแปลงโค้ดให้เป็น vb ด้วยค่ะ

ขอบคุณมากค่ะ
Date : 2011-02-04 23:52:09 By : คนไม่รู้รื่อง
 


 

No. 4



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Code (VB.NET)
    Sub Button1_Click(sender As Object, e As EventArgs)
        Dim chkCusID As CheckBox
        Dim lblID As Label
        Dim i As Integer
        lblText.Text = ""
        For i = 0 To myGridView.Rows.Count - 1
            chkCusID = myGridView.Rows(i).FindControl("chkCustomerID")
            lblID = myGridView.Rows(i).FindControl("lblCustomerID")
            IF chkCusID.Checked = True Then
                '*** Have lblID.Text ***'
                Me.lblText.Text = Me.lblText.Text & "<br>" & lblID.Text
            End IF
        Next
    End Sub


Code (C#)
    void Button1_Click(object sender,EventArgs e)
	{
        CheckBox chkCusID;
        Label lblID;
        int i;
        lblText.Text = "";
        for( i = 0; i <= myGridView.Rows.Count - 1; i++)
		{
            chkCusID = (CheckBox)myGridView.Rows[i].FindControl("chkCustomerID");
            lblID = (Label)myGridView.Rows[i].FindControl("lblCustomerID");
            if(chkCusID.Checked)
			{
                //*** Have lblID.Text ***//
                this.lblText.Text = this.lblText.Text + "<br>" + lblID.Text;
            }
        }
    }

Date : 2011-02-05 22:05:25 By : webmaster
 


 

No. 5



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ปกติ จะใช้ 2 เว็บนี้ครับ

Code
http://www.carlosag.net/Tools/CodeTranslator/
http://www.developerfusion.com/tools/convert/vb-to-csharp/


โพสไว้เผื่อขจำเป็นครับ
Date : 2012-01-16 13:49:59 By : webmaster
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยแปลง code จาก VB.NET เป็น C# ให้หน่อย แนะนำการแปลง VB.NET เป็น C#
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่