Results 1 to 10 of 10

Thread: Easy for you, hard for me! Need a hint!

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2015
    Posts
    7

    Easy for you, hard for me! Need a hint!

    I am currently following a vb.net course and have a issue where I cant wrap my mind around.

    I've got 2 boxes:
    1 is a Select Case with multiple cases where people fill out an input of a currency
    2 is a empty richtextbox

    information:
    A. Someone clicks on a case ( case 1 )
    B. Case opens a inputbox where people input theire input of the current currency rate
    C. After filling out the currency the currency is appended to the richtextbox.
    D. Now I click the next case ( case 2 ) and fill out that currency and its appended to the next line in the richtextbox
    ---- So far so good
    E. Here is the issue : If people click case 1 again and fill out a different number it's appended to line 3, it should edit the number on the first line

    - Note the box needs to be empty at the start so I can't make it static

    kind regards,

    F cremers
    Last edited by Fcremers; Nov 24th, 2015 at 08:55 AM. Reason: not clear enough

  2. #2
    Frenzied Member Gruff's Avatar
    Join Date
    Jan 2014
    Location
    Scappoose Oregon USA
    Posts
    1,293

    Re: Easy for you, hard for me! Need a hint!

    Your description is a bit confusing.
    If you post your code it should become clearer.
    Burn the land and boil the sea
    You can't take the sky from me


    ~T

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2015
    Posts
    7

    Re: Easy for you, hard for me! Need a hint!

    Quote Originally Posted by Gruff View Post
    Your description is a bit confusing.
    If you post your code it should become clearer.
    thanks for responding,

    the code is dutch and has alot of cases, don't think it'll help , I've editted it. Hope its more clear now!

  4. #4
    Fanatic Member
    Join Date
    Aug 2005
    Posts
    606

    Re: Easy for you, hard for me! Need a hint!

    1 is a Select Case with multiple cases where people fill out an input of a currency
    This is confusing because Select Case is a conditional statement used in VB. Maybe it should say I have a listbox with multiple cases?
    Life is about making some things happen, not waiting around for something to happen.

  5. #5
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,900

    Re: Easy for you, hard for me! Need a hint!

    the code is dutch and has alot of cases, don't think it'll help
    Bet you it will. If it's in VB then it's basically in English, even if some of your literal value are in Dutch. It'll be the control statements that we need to see and they'll be in English (or VBenglish). Without seeing your code we can only give you vague answers at best.

    In the spirit of giving a vague answer: it sounds like your algorithm is wrong. It sounds like you're always appending to the rich text box when the user closes the input box. Instead of appending you should be parsing out the text of the rich text box, finding whether their is an appropriate row to update ad updating it if such a row is found. If no such row is found then you would append a new row.

    I can't give you code on how to do that without seeing your existing code though.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2015
    Posts
    7

    Re: Easy for you, hard for me! Need a hint!

    Quote Originally Posted by FunkyDexter View Post
    Bet you it will. If it's in VB then it's basically in English, even if some of your literal value are in Dutch. It'll be the control statements that we need to see and they'll be in English (or VBenglish). Without seeing your code we can only give you vague answers at best.

    In the spirit of giving a vague answer: it sounds like your algorithm is wrong. It sounds like you're always appending to the rich text box when the user closes the input box. Instead of appending you should be parsing out the text of the rich text box, finding whether their is an appropriate row to update ad updating it if such a row is found. If no such row is found then you would append a new row.

    I can't give you code on how to do that without seeing your existing code though.
    Thank you for your help, I indeed keep appending it. I'll look into parsing today and hopefully get it done that way!

    Thank you very much!

  7. #7
    Frenzied Member Gruff's Avatar
    Join Date
    Jan 2014
    Location
    Scappoose Oregon USA
    Posts
    1,293

    Re: Easy for you, hard for me! Need a hint!

    I think I see what you are getting at. You want each line in the textbox to be dedicated to controls that fire inputboxes.

    Line one to always be driven by button 1
    Line two to always be driven by button 2
    ...

    Off hand I would say create an array of strings variable.
    Fill the fixed size Array variable from the inputboxes.
    You can write to each element by its index.

    Dim myArray(4) as string

    myArray(0) = inputbox 'First inputbox
    myArray(1) = inputbox 'Second inputbox
    ...

    After each Array update copy all lines from the Array to the RichTextBox overwriting its contents.

    Are you sure you want to use a richtextbox at all? Will these lines of text be manually edited in the RTB?
    Burn the land and boil the sea
    You can't take the sky from me


    ~T

  8. #8

    Thread Starter
    New Member
    Join Date
    Nov 2015
    Posts
    7

    Re: Easy for you, hard for me! Need a hint!

    Quote Originally Posted by Gruff View Post
    I think I see what you are getting at. You want each line in the textbox to be dedicated to controls that fire inputboxes.

    Line one to always be driven by button 1
    Line two to always be driven by button 2
    ...

    Off hand I would say create an array of strings variable.
    Fill the fixed size Array variable from the inputboxes.
    You can write to each element by its index.

    Dim myArray(4) as string

    myArray(0) = inputbox 'First inputbox
    myArray(1) = inputbox 'Second inputbox
    ...

    After each Array update copy all lines from the Array to the RichTextBox overwriting its contents.

    Are you sure you want to use a richtextbox at all? Will these lines of text be manually edited in the RTB?

    Yes exactly, but now I need a clue on how to do that!
    I'm only on the 9th chapter of the book so it's still hard to figure things out :- (
    How would you do that?

    Code is following in next messege

  9. #9

    Thread Starter
    New Member
    Join Date
    Nov 2015
    Posts
    7

    Re: Easy for you, hard for me! Need a hint!

    Code:
     Private Sub munteenheidlistbox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles munteenheidlistbox.SelectedIndexChanged
            ' On case selection pops up the Inputbox to set a number
            ' When a number is set it checks if its inside the paramets if not pops a msgbox and repops the Inputbox for new user input
            ' On empty line selection pops up a msgbox saying the user should click on a valuta instead.
            Select Case munteenheidlistbox.SelectedIndex
                Case 0
                    americanusdvalue = InputBox("Geef de wisselkoers (> 0 en < 500) voor de Euro tov Amerikaanse dollars (1 Eur = .... Amerikaanse Dollars")
                    Do Until americanusdvalue >= 0 And americanusdvalue <= 500
                        MsgBox("De parameters vallen buiten de wisselkoers. Lees de text nog maals in het volgende scherm")
                        americanusdvalue = InputBox("Geef de wisselkoers (> 0 en < 500) voor de Euro tov Amerikaanse dollars (1 Eur = .... Amerikaanse Dollars")
                    Loop
                Case 2
                    britsepondenvalue = InputBox("Geef de wisselkoers (> 0 en < 500) voor de Euro tov Britse Ponden (1 Eur = .... Britse Ponden")
                    Do Until britsepondenvalue >= 0 And britsepondenvalue <= 500
                        MsgBox("De parameters vallen buiten de wisselkoers. Lees de text nog maals in het volgende scherm")
                        britsepondenvalue = InputBox("Geef de wisselkoers (> 0 en < 500) voor de Euro tov Amerikaanse dollars (1 Eur = .... Amerikaanse Dollars")
                    Loop
                Case 4
                    eurovalue = MsgBox("Wissel koers van Euro naar Euro is altijd 1.")
                    eurovalue = 1
                Case 6
                    russischeroebelvalue = InputBox("Geef de wisselkoers (> 0 en < 500) voor de Euro tov Russische Roebel (1 Eur = .... Russische Roebel")
                    Do Until russischeroebelvalue >= 0 And russischeroebelvalue <= 500
                        MsgBox("De parameters vallen buiten de wisselkoers. Lees de text nog maals in het volgende scherm")
                        russischeroebelvalue = InputBox("Geef de wisselkoers (> 0 en < 500) voor de Euro tov Amerikaanse dollars (1 Eur = .... Amerikaanse Dollars")
                    Loop
                Case 8
                    japanseyenvalue = InputBox("Geef de wisselkoers (> 0 en < 500) voor de Euro tov Japanese Yen (1 Eur = .... Japanse Yen")
                    Do Until japanseyenvalue >= 0 And japanseyenvalue <= 500
                        MsgBox("De parameters vallen buiten de wisselkoers. Lees de text nog maals in het volgende scherm")
                        japanseyenvalue = InputBox("Geef de wisselkoers (> 0 en < 500) voor de Euro tov Amerikaanse dollars (1 Eur = .... Amerikaanse Dollars")
                    Loop
                ' Case else if case not 0-2-4-6 or 8 then gives a messege box.
                Case Else
                    MsgBox("Klik alstublieft op een valuta")
            End Select
    Last edited by Fcremers; Dec 1st, 2015 at 01:43 PM.

  10. #10
    Frenzied Member Gruff's Avatar
    Join Date
    Jan 2014
    Location
    Scappoose Oregon USA
    Posts
    1,293

    Re: Easy for you, hard for me! Need a hint!

    For example:

    Code:
    Public Class Form1
      Dim Lines(4) As String
    
      Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Lines(0) = InputBox("Add Line 1", "", "")
        AddText()
      End Sub
    
      Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Lines(1) = InputBox("Add Line 2", "", "")
        AddText()
      End Sub
    
      Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Lines(2) = InputBox("Add Line 3", "", "")
        AddText()
      End Sub
    
      Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Lines(3) = InputBox("Add Line 4", "", "")
        AddText()
      End Sub
    
      Private Sub AddText()
        With RichTextBox1
          .Clear()
          For Each line As String In Lines
            .AppendText(line & vbNewLine)
          Next
        End With
      End Sub
    End Class
    Burn the land and boil the sea
    You can't take the sky from me


    ~T

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width