请高人帮忙把c#代码转化成vb代码,急用,谢谢!
private void lbxStage_SelectedIndexChanged(object sender, System.EventArgs e)
{
lbxRhythm.Items.Clear ();
lbxMusic.Items.Clear ();// int speed =0;
m_CurStageNo = lbxStage.SelectedIndex + 1;// string myConnectionString="server=LINBELL;UID=mgame;PWD=mgame;database=mgame";
SqlConnection myConnection = new SqlConnection(myConnectionString);
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myConnection; myCommand.CommandText ="SelectRhythmNoByStageNo";
myCommand.CommandType = CommandType.StoredProcedure ; SqlParameter myParm = myCommand.Parameters.Add("@StageNo", SqlDbType.Int , 18);
myCommand.Parameters["@StageNo"].Value = m_CurStageNo ;
myConnection.Open(); SqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
while(myReader.Read())
{
lbxRhythm.Items.Add(myReader["RhythmNo"]);
m_CurNoteTM = int.Parse( myReader["NoteTM"].ToString()) ;
}
myReader.Close(); m_isSelectStage= true;
switch(m_CurNoteTM)
{
case 1000:
lbxSpeed.SelectedIndex = 0;
break;
case 800:
lbxSpeed.SelectedIndex = 1;
break;
case 600:
lbxSpeed.SelectedIndex = 2;
break;
case 480:
lbxSpeed.SelectedIndex = 3;
break;
case 400:
lbxSpeed.SelectedIndex = 4;
break;
default:
// lbxSpeed.SelectedIndex = 0;
break;
} m_isSelectStage = false;
m_isBtnAddClicked=false;
} private void lbxRhythm_SelectedIndexChanged(object sender, System.EventArgs e)
{
lbxMusic.Items.Clear (); m_CurRhythmNo = lbxRhythm.SelectedIndex + 1;
// string myConnectionString="server=LINBELL;UID=mgame;PWD=mgame;database=mgame";
SqlConnection myConnection = new SqlConnection(myConnectionString);
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myConnection; myCommand.CommandText ="SelectMusicByStageNoRythmNo";
myCommand.CommandType = CommandType.StoredProcedure ; SqlParameter myParm = myCommand.Parameters.Add("@StageNo", SqlDbType.Int , 18);
myCommand.Parameters["@StageNo"].Value = m_CurStageNo; myParm = myCommand.Parameters.Add("@RhythmNo", SqlDbType.Int , 18);
myCommand.Parameters["@RhythmNo"].Value = m_CurRhythmNo; myConnection.Open(); SqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
while(myReader.Read())
{
lbxMusic.Items.Add(myReader["DelayTM"]);
}
myReader.Close();
} private void lbxSpeed_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (m_isSelectStage) return;
// int speed =400; switch(lbxSpeed.SelectedIndex)
{
case 0:
m_CurNoteTM = 1000;
m_CurDelayTM = m_CurNoteNM * m_CurNoteTM;
break;
case 1:
m_CurNoteTM = 800;
m_CurDelayTM = m_CurNoteNM * m_CurNoteTM;
break;
case 2:
m_CurNoteTM = 600;
m_CurDelayTM = m_CurNoteNM * m_CurNoteTM;
break;
case 3:
m_CurNoteTM = 480;
m_CurDelayTM = m_CurNoteNM * m_CurNoteTM;
break;
case 4:
m_CurNoteTM = 400;
m_CurDelayTM = m_CurNoteNM * m_CurNoteTM;
break;
default:
break;
}
int cmdresults = 0;// string myConnectionString="server=LINBELL;UID=mgame;PWD=mgame;database=mgame";
SqlConnection myConnection = new SqlConnection(myConnectionString);
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myConnection; myCommand.CommandText = "UpdateDataBySpeed";
myCommand.CommandType = CommandType.StoredProcedure; SqlParameter myParm = myCommand.Parameters.Add("@NoteTM", SqlDbType.Int , 18);
myCommand.Parameters["@NoteTM"].Value = m_CurNoteTM; myConnection.Open(); try
{
cmdresults = myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show("Failed to execute command" + ex.ToString() );
}
myConnection.Close();
// MessageBox.Show("Number of records updated = " + cmdresults.ToString());
} private void lbxMusic_SelectedIndexChanged(object sender, System.EventArgs e)
{
} private void btnDelete_Click(object sender, System.EventArgs e)
{ int cmdresults = 0;// string myConnectionString="server=LINBELL;UID=mgame;PWD=mgame;database=mgame";
SqlConnection myConnection = new SqlConnection(myConnectionString);
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myConnection; myCommand.CommandText = "DeleteMusicByStageNoRhythmNo";
myCommand.CommandType = CommandType.StoredProcedure; SqlParameter myParm = myCommand.Parameters.Add("@Original_StageNo", SqlDbType.Int , 18);
myCommand.Parameters["@Original_StageNo"].Value = m_CurStageNo; myParm = myCommand.Parameters.Add("@Original_RhythmNo", SqlDbType.Int , 18);
myCommand.Parameters["@Original_RhythmNo"].Value = m_CurRhythmNo;
myConnection.Open(); try
{
cmdresults = myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show("Failed to execute command" +ex.ToString ());
}
myConnection.Close(); m_isBtnAddClicked= false;
int temp = (int)m_CurStageNo; if (temp+1 > 20)
{
lbxStage.SelectedIndex = 0;
}
else{
lbxStage.SelectedIndex = temp;
}
lbxStage.SelectedIndex = temp-1;// MessageBox.Show("Number of records deleted = " + cmdresults.ToString());
}
private void lbxStage_SelectedIndexChanged(object sender, System.EventArgs e)
{
lbxRhythm.Items.Clear ();
lbxMusic.Items.Clear ();// int speed =0;
m_CurStageNo = lbxStage.SelectedIndex + 1;// string myConnectionString="server=LINBELL;UID=mgame;PWD=mgame;database=mgame";
SqlConnection myConnection = new SqlConnection(myConnectionString);
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myConnection; myCommand.CommandText ="SelectRhythmNoByStageNo";
myCommand.CommandType = CommandType.StoredProcedure ; SqlParameter myParm = myCommand.Parameters.Add("@StageNo", SqlDbType.Int , 18);
myCommand.Parameters["@StageNo"].Value = m_CurStageNo ;
myConnection.Open(); SqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
while(myReader.Read())
{
lbxRhythm.Items.Add(myReader["RhythmNo"]);
m_CurNoteTM = int.Parse( myReader["NoteTM"].ToString()) ;
}
myReader.Close(); m_isSelectStage= true;
switch(m_CurNoteTM)
{
case 1000:
lbxSpeed.SelectedIndex = 0;
break;
case 800:
lbxSpeed.SelectedIndex = 1;
break;
case 600:
lbxSpeed.SelectedIndex = 2;
break;
case 480:
lbxSpeed.SelectedIndex = 3;
break;
case 400:
lbxSpeed.SelectedIndex = 4;
break;
default:
// lbxSpeed.SelectedIndex = 0;
break;
} m_isSelectStage = false;
m_isBtnAddClicked=false;
} private void lbxRhythm_SelectedIndexChanged(object sender, System.EventArgs e)
{
lbxMusic.Items.Clear (); m_CurRhythmNo = lbxRhythm.SelectedIndex + 1;
// string myConnectionString="server=LINBELL;UID=mgame;PWD=mgame;database=mgame";
SqlConnection myConnection = new SqlConnection(myConnectionString);
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myConnection; myCommand.CommandText ="SelectMusicByStageNoRythmNo";
myCommand.CommandType = CommandType.StoredProcedure ; SqlParameter myParm = myCommand.Parameters.Add("@StageNo", SqlDbType.Int , 18);
myCommand.Parameters["@StageNo"].Value = m_CurStageNo; myParm = myCommand.Parameters.Add("@RhythmNo", SqlDbType.Int , 18);
myCommand.Parameters["@RhythmNo"].Value = m_CurRhythmNo; myConnection.Open(); SqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
while(myReader.Read())
{
lbxMusic.Items.Add(myReader["DelayTM"]);
}
myReader.Close();
} private void lbxSpeed_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (m_isSelectStage) return;
// int speed =400; switch(lbxSpeed.SelectedIndex)
{
case 0:
m_CurNoteTM = 1000;
m_CurDelayTM = m_CurNoteNM * m_CurNoteTM;
break;
case 1:
m_CurNoteTM = 800;
m_CurDelayTM = m_CurNoteNM * m_CurNoteTM;
break;
case 2:
m_CurNoteTM = 600;
m_CurDelayTM = m_CurNoteNM * m_CurNoteTM;
break;
case 3:
m_CurNoteTM = 480;
m_CurDelayTM = m_CurNoteNM * m_CurNoteTM;
break;
case 4:
m_CurNoteTM = 400;
m_CurDelayTM = m_CurNoteNM * m_CurNoteTM;
break;
default:
break;
}
int cmdresults = 0;// string myConnectionString="server=LINBELL;UID=mgame;PWD=mgame;database=mgame";
SqlConnection myConnection = new SqlConnection(myConnectionString);
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myConnection; myCommand.CommandText = "UpdateDataBySpeed";
myCommand.CommandType = CommandType.StoredProcedure; SqlParameter myParm = myCommand.Parameters.Add("@NoteTM", SqlDbType.Int , 18);
myCommand.Parameters["@NoteTM"].Value = m_CurNoteTM; myConnection.Open(); try
{
cmdresults = myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show("Failed to execute command" + ex.ToString() );
}
myConnection.Close();
// MessageBox.Show("Number of records updated = " + cmdresults.ToString());
} private void lbxMusic_SelectedIndexChanged(object sender, System.EventArgs e)
{
} private void btnDelete_Click(object sender, System.EventArgs e)
{ int cmdresults = 0;// string myConnectionString="server=LINBELL;UID=mgame;PWD=mgame;database=mgame";
SqlConnection myConnection = new SqlConnection(myConnectionString);
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myConnection; myCommand.CommandText = "DeleteMusicByStageNoRhythmNo";
myCommand.CommandType = CommandType.StoredProcedure; SqlParameter myParm = myCommand.Parameters.Add("@Original_StageNo", SqlDbType.Int , 18);
myCommand.Parameters["@Original_StageNo"].Value = m_CurStageNo; myParm = myCommand.Parameters.Add("@Original_RhythmNo", SqlDbType.Int , 18);
myCommand.Parameters["@Original_RhythmNo"].Value = m_CurRhythmNo;
myConnection.Open(); try
{
cmdresults = myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show("Failed to execute command" +ex.ToString ());
}
myConnection.Close(); m_isBtnAddClicked= false;
int temp = (int)m_CurStageNo; if (temp+1 > 20)
{
lbxStage.SelectedIndex = 0;
}
else{
lbxStage.SelectedIndex = temp;
}
lbxStage.SelectedIndex = temp-1;// MessageBox.Show("Number of records deleted = " + cmdresults.ToString());
}
解决方案 »
- 找出文件夹内文件最新的更新时间(包括里面的子文件夹哈)
- 在 API Text Viewer 查不到的API函数定义还有什么办法可以获得呢?
- 现代软件设计思路是数据与界面分离,其本质意思是什么?谁能说说?
- SETUP FACTORY 6
- 请问这样的sql语句有问题
- 如何运行一可执行文件?
- 在中文winxp下英文版vb6.0开发的软件在英文版win2000下文本框中的中文显示乱码?
- 如何判斷用戶database還是系統database?
- VB6.0中使用CommonDialog控件创建对话框时,ErrHandler是什么意思?
- 如何让事件调用的过程独占地访问一个数组。
- 如何判断遨游浏览器程序现在都用了哪些ip
- 那位高手有 VB 监控多台三菱PLC的例子?
'Error: Converting Methods, Functions and Constructors
'Error: Converting If-Else-End If Blocks private void lbxStage_SelectedIndexChanged(Object sender, System.EventArgs e)
{
lbxRhythm.Items.Clear ()
lbxMusic.Items.Clear ()
' int speed =0;
m_CurStageNo = lbxStage.SelectedIndex + 1
' string myConnectionString="server=LINBELL;UID=mgame;PWD=mgame;database=mgame";
Dim myConnection As SqlConnection = New SqlConnection(myConnectionString)
Dim myCommand As SqlCommand = New SqlCommand()
myCommand.Connection = myConnection
myCommand.CommandText ="SelectRhythmNoByStageNo"
myCommand.CommandType = CommandType.StoredProcedure
Dim myParm As SqlParameter = myCommand.Parameters.Add("@StageNo",SqlDbType.Int,18)
myCommand.Parameters("@StageNo").Value = m_CurStageNo
myConnection.Open()
Dim myReader As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
While myReader.Read()
lbxRhythm.Items.Add(myReader("RhythmNo"))
m_CurNoteTM = Integer.Parse(myReader("NoteTM").ToString())
End While
myReader.Close()
m_isSelectStage= True
Select Case m_CurNoteTM
Case 1000
lbxSpeed.SelectedIndex = 0
Exit While
Case 800
lbxSpeed.SelectedIndex = 1
Exit While
Case 600
lbxSpeed.SelectedIndex = 2
Exit While
Case 480
lbxSpeed.SelectedIndex = 3
Exit While
Case 400
lbxSpeed.SelectedIndex = 4
Exit While
Case Else
' lbxSpeed.SelectedIndex = 0;
Exit While
End Select
m_isSelectStage = False
m_isBtnAddClicked=False
}
private void lbxRhythm_SelectedIndexChanged(Object sender, System.EventArgs e)
{
lbxMusic.Items.Clear ()
m_CurRhythmNo = lbxRhythm.SelectedIndex + 1
' string myConnectionString="server=LINBELL;UID=mgame;PWD=mgame;database=mgame";
Dim myConnection As SqlConnection = New SqlConnection(myConnectionString)
Dim myCommand As SqlCommand = New SqlCommand()
myCommand.Connection = myConnection
myCommand.CommandText ="SelectMusicByStageNoRythmNo"
myCommand.CommandType = CommandType.StoredProcedure
Dim myParm As SqlParameter = myCommand.Parameters.Add("@StageNo",SqlDbType.Int,18)
myCommand.Parameters("@StageNo").Value = m_CurStageNo
myParm = myCommand.Parameters.Add("@RhythmNo", SqlDbType.Int , 18)
myCommand.Parameters("@RhythmNo").Value = m_CurRhythmNo
myConnection.Open()
Dim myReader As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
While myReader.Read()
lbxMusic.Items.Add(myReader("DelayTM"))
End While
myReader.Close()
}
private void lbxSpeed_SelectedIndexChanged(Object sender, System.EventArgs e)
{
Dim Return As if(m_isSelectStage)
' int speed =400;
Select Case lbxSpeed.SelectedIndex
Case 0
m_CurNoteTM = 1000
m_CurDelayTM = m_CurNoteNM * m_CurNoteTM
Exit While
Case 1
m_CurNoteTM = 800
m_CurDelayTM = m_CurNoteNM * m_CurNoteTM
Exit While
Case 2
m_CurNoteTM = 600
m_CurDelayTM = m_CurNoteNM * m_CurNoteTM
Exit While
Case 3
m_CurNoteTM = 480
m_CurDelayTM = m_CurNoteNM * m_CurNoteTM
Exit While
Case 4
m_CurNoteTM = 400
m_CurDelayTM = m_CurNoteNM * m_CurNoteTM
Exit While
Case Else
Exit While
End Select
Dim cmdresults As Integer = 0
' string myConnectionString="server=LINBELL;UID=mgame;PWD=mgame;database=mgame";
Dim myConnection As SqlConnection = New SqlConnection(myConnectionString)
Dim myCommand As SqlCommand = New SqlCommand()
myCommand.Connection = myConnection
myCommand.CommandText = "UpdateDataBySpeed"
myCommand.CommandType = CommandType.StoredProcedure
Dim myParm As SqlParameter = myCommand.Parameters.Add("@NoteTM",SqlDbType.Int,18)
myCommand.Parameters("@NoteTM").Value = m_CurNoteTM
myConnection.Open()
Try
cmdresults = myCommand.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show("Failed to execute command" + ex.ToString())
End Try
myConnection.Close()
' MessageBox.Show("Number of records updated = " + cmdresults.ToString());
}
private void lbxMusic_SelectedIndexChanged(Object sender, System.EventArgs e)
{
}
private void btnDelete_Click(Object sender, System.EventArgs e)
{
Dim cmdresults As Integer = 0
' string myConnectionString="server=LINBELL;UID=mgame;PWD=mgame;database=mgame";
Dim myConnection As SqlConnection = New SqlConnection(myConnectionString)
Dim myCommand As SqlCommand = New SqlCommand()
myCommand.Connection = myConnection
myCommand.CommandText = "DeleteMusicByStageNoRhythmNo"
myCommand.CommandType = CommandType.StoredProcedure
Dim myParm As SqlParameter = myCommand.Parameters.Add("@Original_StageNo",SqlDbType.Int,18)
myCommand.Parameters("@Original_StageNo").Value = m_CurStageNo
myParm = myCommand.Parameters.Add("@Original_RhythmNo", SqlDbType.Int , 18)
myCommand.Parameters("@Original_RhythmNo").Value = m_CurRhythmNo
myConnection.Open()
Try
cmdresults = myCommand.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show("Failed to execute command" +ex.ToString())
End Try
myConnection.Close()
m_isBtnAddClicked= False
Dim temp As Integer = CType(m_CurStageNo, Integer)
if (temp+1 > 20)
{
lbxStage.SelectedIndex = 0
}
else
{
lbxStage.SelectedIndex = temp
}
lbxStage.SelectedIndex = temp-1
' MessageBox.Show("Number of records deleted = " + cmdresults.ToString());
}
就上面的代码而言就是执行了Connection的打开,执行了SqlCommand,DataReader,在VB6中可以用对应的Connectoin及RecordSet完成