Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Foreign Languages > German Forum
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Math Berechnungen

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-28-2012, 05:32 PM
Senior Member
 
Join Date: Dec 2011
Posts: 147
Default Math Berechnungen

Hi,
Habe ein Problem wie bekommt man den wert zwischen zwei strings?
spricht der string ist "Was sind 10 euro in dollar" ich will nur den wert 10 haben
also zwischen dem wort sind und euro.



kann mir jemand helfen?

Last edited by mcmanu : 01-28-2012 at 05:36 PM.
Reply With Quote
  #2 (permalink)  
Old 01-28-2012, 07:38 PM
Filippo's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Schwäb. Gmünd, Germany
Posts: 977
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hallo mcmanu,

so sollte es gehen.
Code:
Dim wert As Float
Dim string1 As String
Dim strTemp As String
string1=
"Was sind 10 euro in dollar"
strTemp=string1.SubString(string1.IndexOf(
"sind") + 5)
wert=strTemp.SubString2(
0,string1.IndexOf(" "))
msgbox("wert=" & wert)
Ciao,
Filippo
__________________
PPC: MDA Pro, 2GB SD
Device: HTC Desire , Android 2.2
______________________
Reply With Quote
  #3 (permalink)  
Old 01-29-2012, 07:45 AM
Knows the basics
 
Join Date: Nov 2011
Location: Im Paradies
Posts: 83
Default

Hier eine Version, welche ich kürzlich machte um sie universell einsetzen zu können, um Teil Strings zu erhalten aus 2 Abschnitten in der Art von "bring mir den Teilstring, welcher sich zwischen SuchString1 und SuchString2 befindet:

string1="Was sind 10 euro in dollar"


strResultat = fctMiddle(string1, "sind ", "euro")



Sub fctMiddle(sInput As String, sStartKey As String, sEndKey As String) As String
Dim sOutput As String
Dim sTemp As String
Dim iStartPos As Int
Dim iEndPos As Int


iStartPos = sInput.indexOf (sStartKey)

If iStartPos >= 0 Then
iStartPos = iStartPos + sStartKey.length
End If

'Der Endkey wird nur evaluiert, wenn der Startkey gefunden wird.
If iStartPos >= 0 Then
sTemp = sInput.substring2(iStartPos, sInput.length)
iEndPos = sTemp.indexOf ( sEndKey ) + iStartPos
'Auslesen des Wertes
If iEndPos < iStartPos Then

'Der Endkey ("&") kommt nach Startkey nicht mehr im String vor. Bsp: &DocID=33006.
'Wir liefern das Ende des Strings ab Startkey
sOutput = sInput.substring2(iStartPos, sInput.length)

Else If iEndPos = iStartPos Then
'Startkey und Endkey folgen unmittelbar nacheinander. Bsp: &DocID=&
'Wir liefern ein leeren String
sOutput = ""
Else
'Der Startkey und der Endkey kommen wie erwartet im String vor. Bsp: &DocID=33006&MemoType=1
sOutput = sInput.substring2 ( iStartPos, iEndPos )
End If
End If

Return sOutput
End Sub
Reply With Quote
  #4 (permalink)  
Old 01-29-2012, 09:40 AM
Senior Member
 
Join Date: Dec 2011
Posts: 147
Default Danke :)

Wow super Danke euch beiden, werd mich später mal hinhocken und es versuchen

Danke Danke Danke
Reply With Quote
  #5 (permalink)  
Old 01-29-2012, 10:59 AM
JanMucha's Avatar
Newbie
 
Join Date: Jan 2012
Location: Germany, Tuttlingen
Posts: 7
Default String mit Zwischeneinlage

Hallo mcmanu,
so geht es evtl. einfacher:

Dim wert As Float
Dim string1 As String
Dim string2 As String

wert = 10 'dieser Wert kommt soll aus der vorangegangenen Berechnung kommen
string1 = "Was sind "
string2 = " euro in dollar"

msgbox(string1 & wert & string2)
Reply With Quote
  #6 (permalink)  
Old 01-29-2012, 07:31 PM
Senior Member
 
Join Date: Dec 2011
Posts: 147
Default thx

@JanMucha

Danke dir werd mir des mal anschauen und probieren

Thx
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
A little If math problem... Gary Miyakawa Basic4android Updates and Questions 4 08-23-2011 05:59 AM
Math Problem? marathon332 Bugs & wishlist 5 12-27-2010 05:44 PM
Math functions Exp and Log bobsimoneau Basic4android Updates and Questions 5 12-19-2010 12:52 PM
Math help please cdeane Chit Chat 2 04-02-2009 04:45 PM
Help with Math function go4saint Questions (Windows Mobile) 2 03-31-2008 09:15 AM


All times are GMT. The time now is 06:51 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0