Solved

Save Rtf file with name as a date using vb6

Posted on 2015-02-22
7
122 Views
Last Modified: 2015-02-22
I am trying to make a personal reminder program.
I have a calendar control that puts a date into a textbox to be the rtfs file name.
the date format looks like this: 2/21/2015
I get this error:
The specified filename cannot be accessed or is invalid


fName = "C:\Backups\" & txtTaskDate & ".rtf"
debug results fName:
        C:\Backups\2/21/2015.rtf
how can i do this ?
0
Comment
Question by:isnoend2001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 48

Expert Comment

by:Martin Liss
ID: 40624429
Dim a variable like this

Dim MyDate As Date

then MyDate = txtTaskdate
fName = "C:\Backups\" & MyDate & ".rtf"
0
 
LVL 23

Expert Comment

by:yo_bee
ID: 40624430
The Wacks will cause this to error out.
you should parse the date mm-dd-yyyy or something else other than mm/dd/yyyy
Try using :
(Format(Now(), "yyyymmddhhMM")

Open in new window

or
(Format(Now(), "mm-dd-yyyy"))

Open in new window

0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 40624433
Or forget all that and try

fName = "C:\Backups\" & cStr(txtTaskDate) & ".rtf"
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 23

Expert Comment

by:yo_bee
ID: 40624443
The issue you will run into is the / / as invalid characters for a file name
0
 
LVL 48

Assisted Solution

by:Martin Liss
Martin Liss earned 250 total points
ID: 40624445
Yes that's right, I forgot about that.

To change it so that it's acceptable you could do something like

txtTaskDate = Replace(txtTaskdate,"/","-")

or

txtTaskDate = Replace(txtTaskdate,"/","")
0
 
LVL 23

Accepted Solution

by:
yo_bee earned 250 total points
ID: 40624455
Hence my command of format.  Not saying that you can not do it with a replace, but you are adding additional steps rather than a format function.
Sub Test()
Dim mydate As String

mydate = "02/21/2015"


Debug.Print (Format(txtTaskDate, "mm-dd-yyyy"))


End Sub

Open in new window

0
 

Author Closing Comment

by:isnoend2001
ID: 40624826
Both ways work thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month5 days, 3 hours left to enroll

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question