943,532 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 369
  • VB.NET RSS
Jul 2nd, 2009
0

Help with my program!

Expand Post »
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!
Similar Threads
Reputation Points: 19
Solved Threads: 0
Newbie Poster
Manikyr is offline Offline
17 posts
since Jun 2009
Jul 3rd, 2009
0

Re: Help with my program!

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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Reputation Points: 10
Solved Threads: 0
Newbie Poster
scsachira is offline Offline
8 posts
since Jun 2009
Jul 3rd, 2009
0

Re: Help with my program!

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
VB.NET Syntax (Toggle Plain Text)
  1. ....
  2. Dim Ar() as String
  3. ...
  4. Sub AnyHow()
  5. Dim I as Integer=0
  6. if IsNothing(Ar) then
  7. Redim Ar(i)
  8. else
  9. i=Ar.Length
  10. ReDim Preserve Ar(i)
  11. End If
  12. ...
  13. ...
  14. End Sub
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
Jul 3rd, 2009
0

Re: Help with my program!

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
scsachira is offline Offline
8 posts
since Jun 2009
Jul 3rd, 2009
0

Re: Help with my program!

scsachira,

Use bb code tags. Read this http://www.daniweb.com/forums/announcement118-3.html
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
Jul 3rd, 2009
0

Re: Help with my program!

VB Syntax (Toggle Plain Text)
  1.  
  2. Dim Ar() As String
  3. .........
  4.  
  5. Private Sub DoIt()
  6.  
  7. If Ar Is Nothing Then
  8. ReDim Ar(0)
  9. Ar = New String() {TextBox1.Text}
  10. ElseIf Ar.Length = 2 Then
  11. ReDim Ar(0)
  12. Ar = New String() {TextBox1.Text}
  13. Else
  14. ReDim Preserve Ar(Ar.Length)
  15. Ar.SetValue(TextBox1.Text, 1)
  16. End If
  17.  
  18. Label2.Text = TextBox1.Text
  19.  
  20. Label1.Text = ""
  21.  
  22. For i As Int32 = 0 To Ar.Length - 1 Step 1
  23. Label1.Text = Label1.Text & Environment.NewLine & "String " & i + 1 & " = " & Ar(i)
  24. Next
  25.  
  26. End Sub
Reputation Points: 10
Solved Threads: 0
Newbie Poster
scsachira is offline Offline
8 posts
since Jun 2009
Jul 3rd, 2009
0

Re: Help with my program!

I'm new here...
Please ignore my faults...
Is that code solve your problem...
However thanks for Advice..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
scsachira is offline Offline
8 posts
since Jun 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Scanner Device using WIA
Next Thread in VB.NET Forum Timeline: ISAM error





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC