checkAd

    VBA in Excel - brauche hilfe - 500 Beiträge pro Seite

    eröffnet am 06.09.03 14:51:24 von
    neuester Beitrag 06.09.03 16:31:40 von
    Beiträge: 4
    ID: 772.874
    Aufrufe heute: 0
    Gesamt: 2.030
    Aktive User: 0


     Durchsuchen

    Begriffe und/oder Benutzer

     

    Top-Postings

     Ja Nein
      Avatar
      schrieb am 06.09.03 14:51:24
      Beitrag Nr. 1 ()
      Hallo,

      schreibe mir gerade etwas in Visual Basic zusammen. bin erst Anfänger und brauche deshalb Hilfe.
      das problem ist folgendes:
      wie kann man machen, dass eine zahl in einer textbox (von userform) als zahl angesehen wird, und nicht als text?
      ich habe es schon mit fogender funktion versucht, klappt aber nicht:
      WorksheetFunction.Substitute(Anzahl.Value, ",", "." )

      im detail:
      in einer Userform werden zahlen in eine textbox eingegeben (Die Anzahl der Aktien). nun wird mit "if" nachgeschaut ob der wert in dieser textbox kleiner ist als ein anderer wert in einer anderen textbox.
      im editor steht nun folgendes:

      ...
      if Anzahl < Anzahl2 then
      msgbox "if OK"
      ...
      end if

      obwohl "anzahl" kleiner ist als "anzahl2" erscheint die messagebox nicht. das kann eigentlich nur daran liegen, dass die zahl als text gebraucht wird. wie kann ich das nun ändern, dass er die zahlen auch als zahl erkennt?

      jj
      Avatar
      schrieb am 06.09.03 16:05:52
      Beitrag Nr. 2 ()
      Dim a As Integer, str As String
      a = CInt(str)

      ...damit machst Du die Konvertierung ...:D
      Avatar
      schrieb am 06.09.03 16:10:25
      Beitrag Nr. 3 ()
      nach einigen Stunden Suche habe ich die Lösung doch gefunden:

      http://www.fabalou.com/Access/Modules/conversion_functions.a…

      Conversion Functions Explained
      The following is a list of functions available in VB & VBA for converting from one type to another. These function are most useful when you are creating your own functions or want to manipulate a number or text string.

      CBool(expression) This will convert any valid expression into a boolean (true / false) value. The only expressions you can pass to it are the following "True" , "False" "0" or 0 gives false, and any other text or normal number gives true.
      CByte(expression)This is only useful if you want to convert a string, integer, long or double that has a positive value less that 256 into a byte (which takes up less space)
      CCur(expression)Converts any string, integer, long, byte, or double value to a currency value (roughly plus or minus 900 Trillion to four decimal places.
      CDate(expression)Great for converting strings into date format. Accepts most formats for dates. 12/3/99 12-3-99 12 March 1999 e.t.c also accepts numbers counting from 1/1/1899 so 36231.0 is equal to 12/3/1999.
      CDbl(expression)Converts any valid string, long , byte , decimal or currency to double. (You know the scientific format).
      CDec(expression)Converts any valid string, long, byte, double or currency to decimal. That would be numbers up to 79 gazillion (+/-79,228,162,514,264,337,593,543,950,335) or the same with decimal places +/-7.9228162514264337593543950335
      CInt(expression)Converts valid values to integer format (-32,768 to 32,767).
      CLng(expression)Converts valid values to long format (-2,147,483,648 to 2,147,483,647)
      CSng(expression)Converts valid values to single format. (Scientific but not as big as double)
      CVar(expression)Don`t do it, it`s too confusing
      CStr(expression)Converts valid values (numbers, boolean) to string format. Great for doing string calculations on numbers. For instance if you want the first two characters as a number of any long then you can use clng(left(cstr(number),2)). So 2345 would give 23 and 23456 would give 23.


      trotzdem VIELEN DANK an wolaufensie - solche Leute müsste es mehr geben...

      jj
      Avatar
      schrieb am 06.09.03 16:31:40
      Beitrag Nr. 4 ()
      Die Konvertierung erfolgt wie in #2 angegeben mit CInt(Expr) .

      Aber: Ist der Wert der Textbox kein numerischer Ausdruck, kommt es zu einem Fehler.
      Deshalb vorher den Wert in der Textbox mir IsNumeric(Expr) prüfen. Der Rückgabewert der Funkt. ist ein Boolean.

      Also.
      Dim a as Integer

      If IsNumeric(Textbox1.Text) then
      a=CInt(Textbox1.Text)
      else
      `Fehler abfangen
      endif


      Beitrag zu dieser Diskussion schreiben


      Zu dieser Diskussion können keine Beiträge mehr verfasst werden, da der letzte Beitrag vor mehr als zwei Jahren verfasst wurde und die Diskussion daraufhin archiviert wurde.
      Bitte wenden Sie sich an feedback@wallstreet-online.de und erfragen Sie die Reaktivierung der Diskussion oder starten Sie
      hier
      eine neue Diskussion.
      VBA in Excel - brauche hilfe