Help with my program!

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2009
Posts: 17
Reputation: Manikyr is an unknown quantity at this point 
Solved Threads: 0
Manikyr Manikyr is offline Offline
Newbie Poster

Help with my program!

 
0
  #1
Jul 2nd, 2009
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!
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 8
Reputation: scsachira is an unknown quantity at this point 
Solved Threads: 0
scsachira scsachira is offline Offline
Newbie Poster

Re: Help with my program!

 
0
  #2
Jul 3rd, 2009
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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,616
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 469
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: Help with my program!

 
0
  #3
Jul 3rd, 2009
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
  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
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 8
Reputation: scsachira is an unknown quantity at this point 
Solved Threads: 0
scsachira scsachira is offline Offline
Newbie Poster

Re: Help with my program!

 
0
  #4
Jul 3rd, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,616
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 469
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: Help with my program!

 
0
  #5
Jul 3rd, 2009
scsachira,

Use bb code tags. Read this http://www.daniweb.com/forums/announcement118-3.html
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 8
Reputation: scsachira is an unknown quantity at this point 
Solved Threads: 0
scsachira scsachira is offline Offline
Newbie Poster

Re: Help with my program!

 
0
  #6
Jul 3rd, 2009
  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
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 8
Reputation: scsachira is an unknown quantity at this point 
Solved Threads: 0
scsachira scsachira is offline Offline
Newbie Poster

Re: Help with my program!

 
0
  #7
Jul 3rd, 2009
I'm new here...
Please ignore my faults...
Is that code solve your problem...
However thanks for Advice..
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC