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

Konvertierung Zeit und Datum in String

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-09-2008, 11:11 AM
Newbie
 
Join Date: Apr 2008
Posts: 4
Default Konvertierung Zeit und Datum in String

Hallo, ich bin verzweifelt auf der Suche nach einem Stück Coding, dass mir in einem String ein Prefix, ein Datum und die Zeit speichert, das Datum im Format Jahr+Monat+Tag

Bsp: Prefix = "PR" und Datum = 31.05.08 und Zeit = 13:03

Daraus soll werden: PR + 080531 + 1303 also PR0805311303

Ich hatte dazu verschiedene Ansätze:

Dim txtVorgNr
txtVorgNr = "PR" & (DateY & DateM & DateD) & Time

oder

DateFormat ("yymmdd")
txtVorgNr = "PR" & (Date(Now)) & Time

Leider aber gibt es hier immer Fehler. Auch finde ich keinen Befehl, der ein Datum in eine Zeichenkette umwandelt.

Was geht ist die Befehlszeile: txtVorgNr = "PR" & Now

Das ist mir aber zu kryptisch

Danke für eure Hilfe ...
Reply With Quote
  #2 (permalink)  
Old 05-09-2008, 04:40 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hier eine Lösung

Code:
Sub App_Start
    
  Form1.Show
  
  txtVorgNr=DatumZeit

End Sub

Sub DatumZeit
  
Dim tx,txt
    
  tx=SubString(DateY,
2,2)
  txt=
"PR"&tx
  
  tx=DateM
  
If StrLength(tx)=1 Then  ' erg�nzt mit einer 0 falls n�tig
    tx="0"&tx
  
End If
  txt=txt&tx

  tx=DateD
  
If StrLength(tx)=1 Then
    tx=
"0"&tx
  
End If
  txt=txt&tx

  tx=TimeH
  
If StrLength(tx)=1 Then
    tx=
"0"&tx
  
End If
  txt=txt&tx
 
  tx=TimeM
  
If StrLength(tx)=1 Then
    tx=
"0"&tx
  
End If
  txt=txt&tx

  
Return txt
End Sub
Mit Besten Grüssen
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide

Last edited by klaus : 05-09-2008 at 04:55 PM.
Reply With Quote
  #3 (permalink)  
Old 05-09-2008, 05:11 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 1,057
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Hallo ihr beiden,

@klaus: warum denn so kompliziert

Meine Lösung wäre
Code:
DateFormat("yymmdd")
TimeFormat(
"HHmm")
txtVorgNr = 
"PR" & Date(Now) & Time(Now)

Viele Grüße

specci48
Reply With Quote
  #4 (permalink)  
Old 05-09-2008, 09:06 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hallo specci48

Vollkommen einverstanden !

In meiner Gegend gibt es ein Sprichwort das sagt:
Warum einfach machen wenn es auch kompliziert geht ? !

Spass beiseite, Deine Lösung gefällt mir auch besser.

Grüsse.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #5 (permalink)  
Old 05-10-2008, 10:02 AM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 1,057
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by klaus View Post
Warum einfach machen wenn es auch kompliziert geht ? !
Reply With Quote
  #6 (permalink)  
Old 05-12-2008, 07:49 AM
Newbie
 
Join Date: Apr 2008
Posts: 4
Default Prima

Danke für die schnelle Antwort
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
Datum editieren und wieder speichern ? Paulsche German Forum 2 09-26-2008 08:39 AM
put byte value into a string cotralis Questions (Windows Mobile) 5 09-13-2008 03:30 AM
Long String Georg Questions (Windows Mobile) 2 08-06-2008 08:20 AM
Get a input string from user vinians Questions (Windows Mobile) 10 09-04-2007 10:43 PM
OK, next string question Stellaferox Questions (Windows Mobile) 9 06-07-2007 01:12 PM


All times are GMT. The time now is 07:17 PM.


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