Dim op As Integer
Dim cu As String
Dim gs, gs1 As Integer
Dim st, st1, ay, ax As String
op = 0
st = UCase(Trim$(Text1.Text))
st1 = UCase(Trim$(Text2.Text))
gs = Len(st)
gs1 = Len(st1)
If gs > gs1 ThenFor i = 1 To gs
ay = Mid$(st, i, 1)
ax = Mid$(st1, i, 1)
If ay <> ax Then
op = op + 1
cu = cu + ay
If Len(st) >= i Then
st = Left$(st, i - 1) + Right$(st, Len(st) - i)
i = i - 1
End If
Else
End If
Next iIf Option1.Value = True Then
txtsql = "select 批次大  from 出入库明细表 where 批次大='" & UCase(Text1.Text) & "'"
End If
If Option2.Value = True Then
txtsql = "select 批次大 from 鞋面大底出入库明细表 where 批次大='" & UCase(Text1.Text) & "'"
End If
Set myrecord = ExecuteSQL(txtsql, msgtext)
myrecord.MoveFirst
For io = 1 To myrecord.RecordCount
myrecord("批次大") = Trim$(Text2.Text)
myrecord.Update
myrecord.MoveNext
Next ioFor i = 1 To Len(cu)
sttu1 = Mid$(cu, i, 1)
sttu = Mid$(UCase(Trim$(Text1.Text)), 1, j0) + sttu1
If Option1.Value = True Then
txtsql = "select 批次大,批次  from 出入库明细表 where 批次='" & sttu & "'"
End If
If Option2.Value = True Then
txtsql = "select 批次大,批次 from 鞋面大底出入库明细表 where 批次='" & sttu & "'"
End If
Set myrecord = ExecuteSQL(txtsql, msgtext)
If myrecord.RecordCount > 0 Then
myrecord.MoveFirst
For io = 1 To myrecord.RecordCount
myrecord("批次大") = Trim$(sttu)
myrecord.Update
myrecord.MoveNext
Next io
End If
Next i
MsgBox "执行成功"
Elsemyrecord.MoveFirst
For io = 1 To myrecord.RecordCount
myrecord("批次大") = Trim$(Text2.Text)
myrecord.Update
myrecord.MoveNext
Next io
MsgBox "执行成功"
End If
代码如上:请问那位懂VB的高手帮忙改成C# 呀,谢谢先,学习下

解决方案 »

  1.   

     上面的代码主要功能如下 例:原KJ11101ABCDEF 现批次 KJ11101ABCDF 执行后分解为:KJ11101ABCDF 和 KJ11101E 
    例:原KJ11101ABCDEF 现批次 KJ11101ABCDEFH 执行后合成为:KJ11101ABCDFH
      

  2.   

    VB的问题怎么跑到C#专区了哦,不解
      

  3.   

    int op=0;
    string cu="";
    int gs, gs1;
    string st="", st1="", ay="", ax="";
    st = UCase(Text1.Text.Trim()) ;
    st1 = UCase(Text2.Text.Trim());
    gs = st.Length;
    gs1 = st1.Length;
    if (gs > gs1)
    {
        for (int i = 1; i < gs; i++)
        {
            ay = st.Substring(i, 1);
            ax = st1.Substring(i, 1);
            if (ay != ax)
            {
                op++;
                cu += ay;
                if (st.Length >= i)
                {
                    st = st.Substring(0, i - 1) + st.Substring(st.Length - i, i);
                    i = i - 1;
                }
                else
                {
                    //这里有个空操作
                }
            }
        }
        if (Option1.Value)
            txtSql = "select 批次大  from 出入库明细表 where 批次大='" + UCase(Text1.Text) + "'";
        if (Option2.Value)
            txtSql = "select 批次大 from 鞋面大底出入库明细表 where 批次大='" + UCase(Text1.Text) + "'";
        myrecord = ExecuteSQL(txtsql, msgtext); //myrecord类型不明,这里以.net中的DataReader代替
        for (int io = 1; io < myrecord.RecordCount; io++)
        {
            myrecord("批次大") = Text2.Text.Trim();
            myrecord.Update();
        }
        for (int i = 1; i < cu.Length; i++)
        {
            sttu1 = cu.Substring(i, 1);
            sttu = UCase(Text1.Text.Trim()).Substring(i, 1) + sttu1;
            if (Option1.Value)
            {
                txtsql = "select 批次大,批次  from 出入库明细表 where 批次='" + sttu + "'";
            }
            if (Option2.Value)
            {
                txtsql = "select 批次大,批次 from 鞋面大底出入库明细表 where 批次='" + sttu + "'";
            }
            myrecord = ExecuteSQL(txtsql, msgtext); //myrecord类型不明,这里以.net中的DataReader代替
            if (myrecord.RecordCount > 0)
            {
                for (int io = 1; io < myrecord.RecordCount; io++)
                {
                    myrecord("批次大") = Text2.Text.Trim();
                    myrecord.Update();
                }
            }
        }
        MessageBox.Show("执行成功");
    }
    else
    {
        for (int io = 1; io < myrecord.RecordCount; io++)
        {
            myrecord("批次大") = Text2.Text.Trim();
            myrecord.Update();
        }
        MessageBox.Show("执行成功");
    }部分类型和函数不全,无法测试。代码大致如上。