| | |
Help with my program!
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2009
Posts: 17
Reputation:
Solved Threads: 0
I need help with my visual basic assignment!
The program has to include an array with at least two strings.
In the layout there should be one label which explains what the user has to do, for example "Write two strings" (or x strings) and one label that shows the latest inputed string.
There should also exist a textbox which the user use for inputs of strings.
One button to add the strings in the array.
There have to be one meny with the selctions "Show" (that shows the last string from the array and displays it in one label) and "Exit" (to shut down program).
I have read my book correctly, but I doesnt seem the get it anyway!
Can some one explain to me step by step what to do, because I dont know where to start! Everything is up-side-down for the moment!
Please, help me!
Kind regards!
The program has to include an array with at least two strings.
In the layout there should be one label which explains what the user has to do, for example "Write two strings" (or x strings) and one label that shows the latest inputed string.
There should also exist a textbox which the user use for inputs of strings.
One button to add the strings in the array.
There have to be one meny with the selctions "Show" (that shows the last string from the array and displays it in one label) and "Exit" (to shut down program).
I have read my book correctly, but I doesnt seem the get it anyway!
Can some one explain to me step by step what to do, because I dont know where to start! Everything is up-side-down for the moment!
Please, help me!
Kind regards!
•
•
Join Date: Jun 2009
Posts: 8
Reputation:
Solved Threads: 0
I don't understand exactly what u mean...
But try this code... May be it'll help you..
Add this code to command button..
TextBox1 is input text box..
Label1 is shows output you asked for...
In the text box two stings must be separated from coma(",")..
If u don't understand...
Give this text to textbox in runtime.."Sachira,Chinthana,Jayasanka"
Then click command button..
You'll see what happen..
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Label1.Text = ""
Dim x As Array
x = TextBox1.Text.Split(",")
For i As Int32 = 0 To x.Length - 1 Step 1
Label1.Text = Label1.Text & Environment.NewLine & "String " & i + 1 & " = " & x(i)
Next
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
But try this code... May be it'll help you..
Add this code to command button..
TextBox1 is input text box..
Label1 is shows output you asked for...
In the text box two stings must be separated from coma(",")..
If u don't understand...
Give this text to textbox in runtime.."Sachira,Chinthana,Jayasanka"
Then click command button..
You'll see what happen..
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Label1.Text = ""
Dim x As Array
x = TextBox1.Text.Split(",")
For i As Int32 = 0 To x.Length - 1 Step 1
Label1.Text = Label1.Text & Environment.NewLine & "String " & i + 1 & " = " & x(i)
Next
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Manikyr,
Read the following announcement:
1. Homework rules
2. How to use BB code tags?
scsachira,
Use bb code tag. Source code must be surrounded with code tags.
Use ReDim statement to resize an array:
When use click on Add button, value from TextBox1 will be added to an array and a label show a recent added string
Read the following announcement:
1. Homework rules
2. How to use BB code tags?
scsachira,
Use bb code tag. Source code must be surrounded with code tags.
Use ReDim statement to resize an array:
When use click on Add button, value from TextBox1 will be added to an array and a label show a recent added string
VB.NET Syntax (Toggle Plain Text)
.... Dim Ar() as String ... Sub AnyHow() Dim I as Integer=0 if IsNothing(Ar) then Redim Ar(i) else i=Ar.Length ReDim Preserve Ar(i) End If ... ... End Sub
Failure is not fatal, but failure to change might be. - John Wooden
•
•
Join Date: Jun 2009
Posts: 8
Reputation:
Solved Threads: 0
May be this code solve your problem..
In here Label2 show recently added string...
Label1 show both strings...
====================================
Dim Ar() As String
.........
Private Sub DoIt()
If Ar Is Nothing Then
ReDim Ar(0)
Ar = New String() {TextBox1.Text}
ElseIf Ar.Length = 2 Then
ReDim Ar(0)
Ar = New String() {TextBox1.Text}
Else
ReDim Preserve Ar(Ar.Length)
Ar.SetValue(TextBox1.Text, 1)
End If
Label2.Text = TextBox1.Text
Label1.Text = ""
For i As Int32 = 0 To Ar.Length - 1 Step 1
Label1.Text = Label1.Text & Environment.NewLine & "String " & i + 1 & " = " & Ar(i)
Next
End Sub
In here Label2 show recently added string...
Label1 show both strings...
====================================
Dim Ar() As String
.........
Private Sub DoIt()
If Ar Is Nothing Then
ReDim Ar(0)
Ar = New String() {TextBox1.Text}
ElseIf Ar.Length = 2 Then
ReDim Ar(0)
Ar = New String() {TextBox1.Text}
Else
ReDim Preserve Ar(Ar.Length)
Ar.SetValue(TextBox1.Text, 1)
End If
Label2.Text = TextBox1.Text
Label1.Text = ""
For i As Int32 = 0 To Ar.Length - 1 Step 1
Label1.Text = Label1.Text & Environment.NewLine & "String " & i + 1 & " = " & Ar(i)
Next
End Sub
•
•
Join Date: Jun 2009
Posts: 8
Reputation:
Solved Threads: 0
VB Syntax (Toggle Plain Text)
Dim Ar() As String ......... Private Sub DoIt() If Ar Is Nothing Then ReDim Ar(0) Ar = New String() {TextBox1.Text} ElseIf Ar.Length = 2 Then ReDim Ar(0) Ar = New String() {TextBox1.Text} Else ReDim Preserve Ar(Ar.Length) Ar.SetValue(TextBox1.Text, 1) End If Label2.Text = TextBox1.Text Label1.Text = "" For i As Int32 = 0 To Ar.Length - 1 Step 1 Label1.Text = Label1.Text & Environment.NewLine & "String " & i + 1 & " = " & Ar(i) Next End Sub
![]() |
Similar Threads
- Playing .Wav/MIDI files in a Visual Basic Program (Visual Basic 4 / 5 / 6)
- What's the HARDEST program you've written? (Computer Science)
- Cool little Program to disable startup programs (Windows NT / 2000 / XP)
- Program is shutting down right after program is executed (C++)
- 3d Program (Game Development)
Other Threads in the VB.NET Forum
- Previous Thread: Scanner Device using WIA
- Next Thread: ISAM error
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account application arithmetic array basic bing button buttons center check code combobox component crystalreport data database datagrid datagridview date design dissertation dissertations dropdownlist excel fade file-dialog filter ftp generatetags google gridview hardcopy hosting images input insert intel internet listview mobile monitor ms net networking objects output panel passingparameters peertopeervideostreaming picturebox picturebox1 port position print printing problem problemwithinstallation project remove save searchbox searchvb.net select serial shutdown soap survey table tcp temperature text textbox timer timespan toolbox trim update updown user vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf year






