开发者

How to generate a string based on multiple different values?

I'm currently working on a library system on Excel with VBA and I need a function to generate a book's call number based on its title, author and the date.

Here's an example of my coding

dim title, author, date, callnumber as string

title = "Book 1"
title = UCase(title)
author = "Author 1"
author = UCase(author)
date = NOW()

'i'll need to generate the call number
callnumber = ............??????????

Using the above examples, the program should generate a call number for the book based on the author, title, and the date. I would prefer it to have the first 3 letters of the "author", hyphen "-", first 3开发者_JAVA百科 letters of "title", hyphen "-", and the date in numbers.

For example if the date is 3 March 2011, the generated call number would be : "AUT-TIT-03032011"

For date = "29 February 2012, title = "The Stickman", author = "John Lee", the generated value should be: "JOH-THE-29022011"

Can someone please help me? Thanks a lot!


callnumber = MID(author,1,3)&"-"&MID(title,1,3)&"-"&Format(date, "ddmmyyyy")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜