[RESOLVED] [VBA] Convert a string from a TextBox to a number with point as decimal separator-VBForums
Results 1 to 4 of 4

Thread: [RESOLVED] [VBA] Convert a string from a TextBox to a number with point as decimal separator

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2011
    Posts
    7

    Resolved [RESOLVED] [VBA] Convert a string from a TextBox to a number with point as decimal separator

    I need to pass a number from a TexBox with this format 1,2 to a sql string in this format 1.2

    My locale is It-it and uses decimal point with a comma (1,2).

    How can I do this change in VBA? I wrote this code...

    Code:
    Private Sub insert_article_Click()
    'set decimal separator as point
    With Application
    	.DecimalSeparator = "."
    	.ThousandsSeparator = ","
    	.UseSystemSeparators = False
    End With
    Dim number As Double
    Dim word As String
    word = "test"
    number = CDbl(Textnumber.Value) 'if I enter 1,2 ,number will be 1,2
    'I try also this, but number will be 1,2
    'number = Replace(Textnumber.Value, ".", ",")
    strSQL = "INSERT INTO table (col_word, col_number) VALUES ('" & word & "'," & number & ")"
    ...
    End Sub
    Thanks, Paolo

  2. #2

    Thread Starter
    New Member
    Join Date
    Mar 2011
    Posts
    7

    Resolved [VBA] Convert a string from a TextBox to a number with point as decimal separator

    The correct string is
    Code:
    Dim number As String
    number = Replace(Textnumber.Value, ",", ".")

  3. #3
    Registered User
    Join Date
    Jan 2016
    Posts
    1

    Re: [RESOLVED] [VBA] Convert a string from a TextBox to a number with point as decima

    hi. a blind it student, doing a application, in c#, if this is not the right forum, is there a c # and wpf forum, also, can you help me. will paste the following code and need to convert from double to string only one read only text box, can you help. have been trying to google and find an answer, have not found one yet. so if any one able to help, i use the jaws for windows screen reader for jaws from http://www.freedomscientific.com, got the program debugged and down to 99 %, so, tearing my hair out and have been trying for days, to try to find an answer, what am i doing wrong? am i an idiot? am i dumb, hard hard to visualise the stack, and the push, pop, and the text boxe results when you cannot see, did have some sight when i was younger, got rp, now and totally blind. so can any one help. in adelaide, in australia. so will paste the button equals click event to this thread, any one able to help me out, any examples, or point me to some examples, have tried searching 50 or more pages, have not found an answer. tearing my hair out. marvin. ps: if you can help, would be appreciative, for a school project, not to do it for me, but how to fix this little problem, have read the documentation, but maybe i am not just getting it. want to learn and have debugged and fixed all the other errors, and visual studio community 2015, says tracking error, the description of the error, and the line number, so that's a lot help ful. so will paste below. help if you can, want to get this little puppy done, error free, and then test this little puppy. marvin. ps:: pasting below. private void btnEqual_Click(object sender, RoutedEventArgs e)
    {
    if (string.IsNullOrEmpty(Result.Text))
    return;

    try {
    Result.Text = Evaluate(Result.Text);
    }
    catch(DivideByZeroException e) {
    Result.Text = "Error: divide by zero detected!"
    }

    }

  4. #4
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,461

    Re: [RESOLVED] [VBA] Convert a string from a TextBox to a number with point as decima

    this tiny segment is not enough to really help you as it is related to the rest of the code.

    exactly what the button is supposed to do, would be a useful starting point.

    happy to help

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.