代码改写,可以换成相应的控件,text1,2换成textbox1,textbox2,option1,2换成radioButton1,2

ksrun 2008-07-08 11:07:43
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 Then

For 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 i

If 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 io

For 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 "执行成功"
Else

myrecord.MoveFirst
For io = 1 To myrecord.RecordCount
myrecord("批次大") = Trim$(Text2.Text)
myrecord.Update
myrecord.MoveNext
Next io
MsgBox "执行成功"
End If


代码如上:请问那位懂VB的高手帮忙改成C# 呀,谢谢先,学习下
...全文
81 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaojing7 2008-07-10
  • 打赏
  • 举报
回复
vb不解!
江城老温 2008-07-10
  • 打赏
  • 举报
回复
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("执行成功");
}


部分类型和函数不全,无法测试。代码大致如上。
songyingjian2008 2008-07-10
  • 打赏
  • 举报
回复
VB不太懂
ksrun 2008-07-08
  • 打赏
  • 举报
回复
上面的代码主要功能如下 例:原KJ11101ABCDEF 现批次 KJ11101ABCDF 执行后分解为:KJ11101ABCDF 和 KJ11101E
例:原KJ11101ABCDEF 现批次 KJ11101ABCDEFH 执行后合成为:KJ11101ABCDFH
正宗熊猫哥 2008-07-08
  • 打赏
  • 举报
回复
不解
beancurd005 2008-07-08
  • 打赏
  • 举报
回复
VB的问题怎么跑到C#专区了哦,不解。。。

110,617

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧