Question Return a value

Dallas72

New member
Joined
Jan 1, 2020
Messages
2
Programming Experience
Beginner
Hi I hope to get some help.
What I want to do is bring a TextBox and a int to a function that returns a string.

C#:
public string CheckIf(TextBox textBoxTemp_1, int Temp)
        {
            string TextBoxTemp_2;
            if (textBoxTemp_1.TextLength <= 0)
            {
                string[] TextBox_1 = new string[Temp];
                foreach (var item in TextBox_1)
                {
                    TextBoxTemp_20 += item + "\r\n";
                }
                TextBoxTemp_2 = TextBoxTemp_20;
                return TextBoxTemp_2;
            }
        }
 
Last edited by a moderator:
What is the returned string supposed to contain?

Can you give us examples of inputs and expected outputs?
 
What I want to do is bring a TextBox and a int to a function that returns a string.
Congratulations, because that's exactly what you're doing. Presumably you are saying, without actually saying, that the string that is returned is not what you expect. If you want us to tell you how to change your code to implement the logic you want then you probably ought to explain what that logic is. You might start by changing the name of the method to something that describes that logic. CheckIf is a bad name because it could mean almost anything, e.g. maybe you want to check if there's a dragon under your bed.
 
That was a bad description of me.
Then I try again :).
The program I am trying to do is to load * .dat file and edit the file.
If you open a blank * .Dat file, it looks like this.
// VARNAME
/// SHARE 1000,1000,1000,1000,1000,1024,1024,1024
/// B
///IN
/// D
/// R
/// S
/// P
/// BP
///EX
But between each ex. /// B to /// I should have 1000 empty rows.

So I have a TextBox for each so there are 8 textboxes.
So what I want to do is that if some of TextBox is empty, add 1000 empty rows when I save the file.

Här ser ni min exempelkod.
I think the problem is see the highlighted text.
C#:
private void Test()
{
    string Test_1 = CheckIfTextBoxEmpty(TextBox1, 1000);
}

public string CheckIfTextBoxEmpty(TextBox textBoxTemp_1, int Temp)
{
    string TextBoxTemp_2;
    if (textBoxTemp_1.TextLength <= 0)
    {
        string[] TextBox_1 = new string[Temp];
        foreach (var item in TextBox_1)
        {
            TextBoxTemp_20 += item + "\r\n";
        }
        TextBoxTemp_2 = TextBoxTemp_20;
        return TextBoxTemp_2;
    }
}
 
Last edited by a moderator:
I already formatted your code once in this thread and asked you to do so yourself in future. Now I have done it again. Please make the effort to help us help you by posting code as clearly as possible, which means applying the specific code formatting provided by the editor.
 
Back
Top Bottom