Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Foreign Languages > German Forum
Home Register FAQ Members List 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 Veteran
 
Join Date: Oct 2007
Location: Switzerland
Posts: 434
Awards Showcase
Competition Winner 
Total Awards: 1
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

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: 531
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 Veteran
 
Join Date: Oct 2007
Location: Switzerland
Posts: 434
Awards Showcase
Competition Winner 
Total Awards: 1
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
Reply With Quote
  #5 (permalink)  
Old 05-10-2008, 10:02 AM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 531
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
GPS serialdevice : 3 sentence in one string alea46 Questions & Help Needed 3 06-19-2008 08:06 PM
String and Shell questions HARRY Questions & Help Needed 4 12-18-2007 05:56 PM
Remove spaces from string forisco Questions & Help Needed 2 11-16-2007 10:07 AM
checking textbox string derez Questions & Help Needed 13 10-25-2007 11:58 AM
OK, next string question Stellaferox Questions & Help Needed 9 06-07-2007 01:12 PM


All times are GMT. The time now is 05:54 PM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0