如果文本框以“R”开头,则然后转到B列,否则以“s”开头。然后转到C列 [英] If textbox starts with "R" then goto B column if else starts with "s" then goto C column

查看:110
本文介绍了如果文本框以“R”开头,则然后转到B列,否则以“s”开头。然后转到C列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Frnds



i在Windows窗体应用程序中有5个文本框,还有1个按钮。

如果按钮单击文本框值goto excel列。

但我想如果textbox以R开头,则必须在excel中使用B列。如果以S开头,则必须在excel中使用C列。



我尝试过:



在按钮中我将vs2010写入excel转换器格式。

Hi Frnds

i have 5 textbox in windows form application ,and 1 button.
if buttons clicks textbox value goto excel columns .
but i want if textbox starts with "R" it have to B column in excel. if its starts with "S" it have to go C column in excel.

What I have tried:

In Button i wrote vs2010 to excel converter format.

//In textbox //
  if(textBox1.Text.length==7)  // 7 is a length of textbox //
     textbox2.focus();        // automatically goto next textbox //



并为分配特定的行和列我尝试下面的编码


and for assign specific rows and columns i try below coding

    int i=0
string str1=BarCode[i].substring[0,1];
       if(str1=="R")
        {
      for(int j=0; j<i;j++)
        {
       if(xlworksheet.cells [j+1,2]==null)
        {
       xlworksheet.cells[j+1,2]=BarCode[i];
break;
       else
       xlworksheet.cells[j+2,2]=BarCode[i];
      }
     }
      else if (str=="S")
     {
     for(int k=0; k<i; k++)
     if(xlworksheet.cells[k+1,3]==null)
    {
xlworksheet.cells[k+1,3]=BarCode[i];
break;
}
else xlworksheet.cells[k+2,3]=BarCode[i];
}
}
}



在此代码中,我的格式不正确。

frnds请帮助我


In this code i didn't get correct format.
frnds pls help me

推荐答案

我们无法分辨 - 太多取决于您的数据内容,以及实际代码的时间被执行了:我们无法控制它,也不能在这里测试它。



所以,它将取决于你。

在函数的第一行放置一个断点,并通过调试器运行代码。然后查看您的代码,并查看您的数据并找出手动应该发生的事情。然后单步执行每一行检查您预期发生的情况正是如此。如果不是,那就是当你遇到问题时,你可以回溯(或者再次运行并仔细观察)以找出原因。


抱歉,但我们不能为您做到这一点 - 时间让您学习一门新的(非常非常有用的)技能:调试!
We can't tell - too much depends on the content of your data, and when that code actually gets executed: and we have no control over that, nor can we test it here.

So, its going to be up to you.
Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!


建议:学会正确缩进代码,它有助于阅读,因为它显示了结构。

Advice: learn to properly indent your code, it helps reading as it shows the structure.
int i=0
string str1=BarCode[i].substring[0,1];
if(str1=="R")
{
	for(int j=0; j<i;j++)
	{
		if(xlworksheet.cells [j+1,2]==null)
		{
			xlworksheet.cells[j+1,2]=BarCode[i];
			break;
			else
				xlworksheet.cells[j+2,2]=BarCode[i];
		}
	}
	else if (str=="S")
	{
		for(int k=0; k<i; k++)
			if(xlworksheet.cells[k+1,3]==null)
			{
				xlworksheet.cells[k+1,3]=BarCode[i];
				break;
			}
			else
				xlworksheet.cells[k+2,3]=BarCode[i];
	}
}
}



这不编译,结构错误。

建议:不要在一行代码中打包,任何保存的行都是以牺牲可读性为代价。


This do not compile, the structure is wrong.
Advice: do not pack things in a single line of code, any line saved is at the expense of readability.


实际上没有人知道回答我的问题.....
Actually no one knows answer my question .....


这篇关于如果文本框以“R”开头,则然后转到B列,否则以“s”开头。然后转到C列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆