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
neuester Beitrag 06.09.03 16:31:40 von
Beiträge: 4
ID: 772.874
ID: 772.874
Aufrufe heute: 0
Gesamt: 2.030
Gesamt: 2.030
Aktive User: 0
Top-Diskussionen
Titel | letzter Beitrag | Aufrufe |
---|---|---|
vor 43 Minuten | 7916 | |
vor 38 Minuten | 7558 | |
vor 1 Stunde | 4853 | |
heute 20:51 | 4073 | |
vor 41 Minuten | 2734 | |
02.02.07, 20:48 | 2692 | |
vor 40 Minuten | 1975 | |
vor 48 Minuten | 1805 |
Meistdiskutierte Wertpapiere
Platz | vorher | Wertpapier | Kurs | Perf. % | Anzahl | ||
---|---|---|---|---|---|---|---|
1. | 1. | 18.735,00 | +1,25 | 208 | |||
2. | 7. | 0,3100 | -67,71 | 116 | |||
3. | 4. | 0,2100 | +8,53 | 102 | |||
4. | 2. | 171,96 | -1,58 | 54 | |||
5. | 38. | 2,7500 | +9,13 | 51 | |||
6. | 12. | 0,1645 | -5,46 | 39 | |||
7. | 9. | 6,6570 | +0,14 | 39 | |||
8. | 5. | 4,1525 | -0,48 | 34 |
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
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
Dim a As Integer, str As String
a = CInt(str)
...damit machst Du die Konvertierung ...
a = CInt(str)
...damit machst Du die Konvertierung ...
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
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
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
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 eine neue Diskussion.
Meistdiskutiert
Wertpapier | Beiträge | |
---|---|---|
201 | ||
110 | ||
100 | ||
52 | ||
47 | ||
41 | ||
38 | ||
34 | ||
33 | ||
30 |
Wertpapier | Beiträge | |
---|---|---|
30 | ||
25 | ||
25 | ||
24 | ||
16 | ||
15 | ||
14 | ||
13 | ||
11 | ||
10 |