请高手指点:怎样把C#程序转化为vb.net程序,万分感谢
如下程序:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSyst...
如下程序:
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.Data.SqlClient;
namespace prohor
{
public partial class OpenPro : Form
{
SqlConnection m_connection;
public form frm1;
public OpenPro(form frm1)
{
InitializeComponent();
this.frm1 = frm1;
}
private void OpenPro_Load(object sender, EventArgs e)
{
string constr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\App_Data\yccs.mdf;Integrated Security=True;User Instance=True;";
m_connection = new SqlConnection(constr);
SqlDataAdapter m_DA = new SqlDataAdapter("SELECT * FROM YcwxDate", m_connection);
SqlCommandBuilder m_sqlCommandBuilder = new SqlCommandBuilder(m_DA);
try
{
m_connection.Open();
DataTable m_dtYcwx = new DataTable();
m_DA.Fill(m_dtYcwx);
for (int i = 0; i < m_dtYcwx.Rows.Count; i++)
{
if (!comboBox1.Items.Contains(m_dtYcwx.Rows[i]["油藏名称"].ToString()))
{
comboBox1.Items.Add(m_dtYcwx.Rows[i]["油藏名称"].ToString());
}
}
}
catch (Exception)
{
throw;
}
}
private void button1_Click(object sender, EventArgs e)
{
if (comboBox1.Text != "")
{
m_connection.Dispose();
m_connection.Close();
this.DialogResult = DialogResult.OK;
}
else
{
MessageBox.Show("尚未选中工程");
}
}
private void button2_Click(object sender, EventArgs e)
{
m_connection.Dispose();
m_connection.Close();
this.DialogResult = DialogResult.Cancel;
}
private void label1_Click(object sender, EventArgs e)
{
}
}
} 展开
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.Data.SqlClient;
namespace prohor
{
public partial class OpenPro : Form
{
SqlConnection m_connection;
public form frm1;
public OpenPro(form frm1)
{
InitializeComponent();
this.frm1 = frm1;
}
private void OpenPro_Load(object sender, EventArgs e)
{
string constr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\App_Data\yccs.mdf;Integrated Security=True;User Instance=True;";
m_connection = new SqlConnection(constr);
SqlDataAdapter m_DA = new SqlDataAdapter("SELECT * FROM YcwxDate", m_connection);
SqlCommandBuilder m_sqlCommandBuilder = new SqlCommandBuilder(m_DA);
try
{
m_connection.Open();
DataTable m_dtYcwx = new DataTable();
m_DA.Fill(m_dtYcwx);
for (int i = 0; i < m_dtYcwx.Rows.Count; i++)
{
if (!comboBox1.Items.Contains(m_dtYcwx.Rows[i]["油藏名称"].ToString()))
{
comboBox1.Items.Add(m_dtYcwx.Rows[i]["油藏名称"].ToString());
}
}
}
catch (Exception)
{
throw;
}
}
private void button1_Click(object sender, EventArgs e)
{
if (comboBox1.Text != "")
{
m_connection.Dispose();
m_connection.Close();
this.DialogResult = DialogResult.OK;
}
else
{
MessageBox.Show("尚未选中工程");
}
}
private void button2_Click(object sender, EventArgs e)
{
m_connection.Dispose();
m_connection.Close();
this.DialogResult = DialogResult.Cancel;
}
private void label1_Click(object sender, EventArgs e)
{
}
}
} 展开
1个回答
展开全部
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports System.Data.SqlClient
Namespace prohor
Public Partial Class OpenPro
Inherits Form
Private m_connection As SqlConnection
Public frm1 As form
Public Sub New(frm1 As form)
InitializeComponent()
Me.frm1 = frm1
End Sub
Private Sub OpenPro_Load(sender As Object, e As System.EventArgs) Handles OpenPro.Load
Dim constr As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\App_Data\yccs.mdf;Integrated Security=True;User Instance=True;"
m_connection = New SqlConnection(constr)
Dim m_DA As New SqlDataAdapter("SELECT * FROM YcwxDate", m_connection)
Dim m_sqlCommandBuilder As New SqlCommandBuilder(m_DA)
Try
m_connection.Open()
Dim m_dtYcwx As New DataTable()
m_DA.Fill(m_dtYcwx)
Dim i As Integer = 0
While i < m_dtYcwx.Rows.Count
If Not comboBox1.Items.Contains(m_dtYcwx.Rows(i)("油藏名称").ToString()) Then
comboBox1.Items.Add(m_dtYcwx.Rows(i)("油藏名称").ToString())
End If
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Catch generatedExceptionName As Exception
Throw
End Try
End Sub
Private Sub button1_Click(sender As Object, e As System.EventArgs) Handles button1.Click
If comboBox1.Text <> "" Then
m_connection.Dispose()
m_connection.Close()
Me.DialogResult = DialogResult.OK
Else
MessageBox.Show("尚未选中工程")
End If
End Sub
Private Sub button2_Click(sender As Object, e As System.EventArgs) Handles button2.Click
m_connection.Dispose()
m_connection.Close()
Me.DialogResult = DialogResult.Cancel
End Sub
Private Sub label1_Click(sender As Object, e As System.EventArgs) Handles label1.Click
End Sub
End Class
End Namespace
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports System.Data.SqlClient
Namespace prohor
Public Partial Class OpenPro
Inherits Form
Private m_connection As SqlConnection
Public frm1 As form
Public Sub New(frm1 As form)
InitializeComponent()
Me.frm1 = frm1
End Sub
Private Sub OpenPro_Load(sender As Object, e As System.EventArgs) Handles OpenPro.Load
Dim constr As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\App_Data\yccs.mdf;Integrated Security=True;User Instance=True;"
m_connection = New SqlConnection(constr)
Dim m_DA As New SqlDataAdapter("SELECT * FROM YcwxDate", m_connection)
Dim m_sqlCommandBuilder As New SqlCommandBuilder(m_DA)
Try
m_connection.Open()
Dim m_dtYcwx As New DataTable()
m_DA.Fill(m_dtYcwx)
Dim i As Integer = 0
While i < m_dtYcwx.Rows.Count
If Not comboBox1.Items.Contains(m_dtYcwx.Rows(i)("油藏名称").ToString()) Then
comboBox1.Items.Add(m_dtYcwx.Rows(i)("油藏名称").ToString())
End If
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Catch generatedExceptionName As Exception
Throw
End Try
End Sub
Private Sub button1_Click(sender As Object, e As System.EventArgs) Handles button1.Click
If comboBox1.Text <> "" Then
m_connection.Dispose()
m_connection.Close()
Me.DialogResult = DialogResult.OK
Else
MessageBox.Show("尚未选中工程")
End If
End Sub
Private Sub button2_Click(sender As Object, e As System.EventArgs) Handles button2.Click
m_connection.Dispose()
m_connection.Close()
Me.DialogResult = DialogResult.Cancel
End Sub
Private Sub label1_Click(sender As Object, e As System.EventArgs) Handles label1.Click
End Sub
End Class
End Namespace
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询