Simple Task Solutions: Print Textbox and Replace Letters

  • Thread starter i try
  • Start date
  • Tags
    Hello
In summary: OK, let's take it from the top.The first thing you should realize is that you need to create a function to handle the string creation. This function will take in two arguments- the number of lines to be created and the text to be used.Once the function is created, you can start to code. Within the function, you will need to first create a string variable to store the string that you will be creating. Next, you will need to loop through the number of lines that you specified and create a string for each line. Finally, you will add a space and a carriage return to the end of the string.
  • #1
i try
2
0
I need help in solving the two simple task, and I will be very grateful if you helped me.

1)Write a program that prints the textbox:


1
121
12321
1234321
123454321

2) Write a program that brings the input sentence.In this sentence instead of the letter A there is the letter X and show theat into the newly obtained string.

Thanks a lot!
 
Technology news on Phys.org
  • #2
i try said:
I need help in solving the two simple task, and I will be very grateful if you helped me.

1)Write a program that prints the textbox:


1
121
12321
1234321
123454321

2) Write a program that brings the input sentence.In this sentence instead of the letter A there is the letter X and show theat into the newly obtained string.

Thanks a lot!

Hey i try and welcome to the forums.

Can you show us any code you've written along with any of your thoughts and what you've tried and thought about trying?
 
  • #3
chiro said:
Hey i try and welcome to the forums.

Can you show us any code you've written along with any of your thoughts and what you've tried and thought about trying?

I tried to do that, but we do not succeed.

here code:


Public Class Form1
Dim m(10) As Char
Dim i, j, pr As Integer
Dim unos As Char
Dim postoji As Boolean


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Do While i < 11
postoji = False
unos = InputBox("unesi nesto")
ListBox1.Items.Add(unos)


For j = 1 To i - 1
If unos = m(j) Then
postoji = True
pr = j

End If
Next
Loop

If Not (postoji) Then
m(i) = unos
i = i + 1

i = i - 1

End If
 
  • #4
I'm going to put your code in the tags first.

To do this you use the CODE tag with the square braces with /CODE at the end.

Code:
Public Class Form1
    Dim m(10) As Char
    Dim i, j, pr As Integer
    Dim unos As Char
    Dim postoji As Boolean    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Do While i < 11
            postoji = False
            unos = InputBox("unesi nesto")
            ListBox1.Items.Add(unos)            For j = 1 To i - 1
                If unos = m(j) Then
                    postoji = True
                    pr = j

                End If
            Next
        Loop

        If Not (postoji) Then
            m(i) = unos
            i = i + 1
        
            i = i - 1

        End If
End Form1
 
  • #5
Is this Python?
 
  • #6
OK, let's take it from the top.

The first thing you should realize that for creating the string is that you should decompose your string creation into just one routine that creates the string for the textbook (using an actual string object) and then assign this string to the value of the textbook.

For this function we should give the number of lines we want to create and then pass that to a function. Since this is a small routine, I'll write the routine and get your take on it.

Code:
Sub CalculateString(String s, ByVal n As Integer)
   s = ""
  
   dim x as integer
   dim i as integer
 
   for x = 1 to n
        for i = 1 to x
           s = s + Trim(Str(x))  
        end for
        for i = x-1 to 1
           s = s + Trim(Str(x))
        end for
        s = s + VbCrLf 
   end for
End Sub

I'm assuming that you pass the string by reference instead of by value and you could turn this into a function if you want to.
 
  • #7
jtbell said:
Is this Python?

It's Visual Basic.
 

1. What is "Hello im new in this one and i"?

"Hello im new in this one and i" is a phrase commonly used by new users in online communities to introduce themselves and ask for guidance or support.

2. Is "Hello im new in this one and i" a specific platform or website?

No, "Hello im new in this one and i" is not a specific platform or website. It is a general phrase that can be used on various online platforms and forums.

3. Why do people use "Hello im new in this one and i"?

People use "Hello im new in this one and i" to introduce themselves to a new online community and to seek help or advice from more experienced members.

4. How should I respond to someone who says "Hello im new in this one and i"?

If you are an experienced member, you can respond by welcoming the new user and offering assistance or resources to help them get started. If you are also new, you can reply with your own introduction and ask for help or advice from others.

5. Are there any rules or guidelines for using "Hello im new in this one and i"?

There are no strict rules or guidelines for using "Hello im new in this one and i", but it is important to be respectful and follow the community guidelines when introducing yourself and interacting with others.

Similar threads

  • Programming and Computer Science
Replies
9
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
12
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
Replies
10
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
  • Computing and Technology
Replies
1
Views
2K
  • STEM Academic Advising
Replies
13
Views
2K
  • Set Theory, Logic, Probability, Statistics
3
Replies
93
Views
16K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
Back
Top