Combining 2 variables

T

Tom Petersen

Brand new to .aspx, and just modifying code.

I have this:
writer.WriteLine("DTSTART:" &
beginDate.ToUniversalTime.ToString("yyyyMMdd\THHmmss\Z") )

I am grabbing the date and time from two fields and just need to combine
them into one string for the above to work and I don't know how in .aspx.

Here are my fields I am trying to combine, it also look slike there
shouldn't be a space between them, looking at the above lines:

Dim beginDate as Date = Request.Form.GetValues("date")(0)
Dim beginTime as StartTime = Request.Form.GetValues("StartTime")(0)

So in other words, I need to append StartTime to beginTime so the whole
value will show up. This is for making an Outlook Celendar appointment,
BTW.
 
R

recoil

FYI. You should be using ASP.NET Server controls and thus your ASPX
markup should look something like this. Please note that naming
convention can vary i just prefer Hungarian notation because it makes
long term maintainability alot easier.
<asp:TextBox Id="txtBeginDate" runat="Server" />
<asp:TextBox Id="txtBeginTime" runat="Server" />

Your codebehind should look something like this.
String strBeginDate = txtBeginDate.Text.Trim() + " " +
txtBeginTime.Text.Trim();
then you could say
DateTime FullBeginDate = DateTime DateTime.Parse(FullBeginDate); or
use a ParseExact variant, depending upon your needs.

Hope this helps to clear some stuff up and open some other avenues.
 
T

Tom Petersen

Still not quite getting it sorry.
I have these and it is pulling in the data correctly:
Dim beginDate as Date = Request.Form.GetValues("date")(0)
Dim beginTime as Date = Request.Form.GetValues("sTime")(0)

Now I just need to combine those two values into one varible, I didn't quite
understand that code.
Is there a way to just do something like
beginDate = beginDate + beginTime
or
beginDate = beginDate & beginTime

I also looked into the .append but I am guessing since I am dealing with a
date vs. a string this won't work???
This code is doing some conversion for me, but this is where I already need
the combined data:
writer.WriteLine("DTSTART:" &
beginDate.ToUniversalTime.ToString("yyyyMMdd\THHmmss\Z") )

I hate to be a pain, but could you try (using my variable) shoot some more
code at me I can play with??

Thanks a million!!!
 
R

recoil

That is not really the standard method of doing what you are attempting
to accomplish. Your method is extremely backwards and requires going
through a bunch of unnecessary loops
Try this but once again this is NOT the preferred method of doing this.
You could actually combine this in shorter code but since it seems like
you are very new I am going to spell it out so that you can see all of
the steps being taken out. Before you can lean to walk you must first
learn to crawl.

Dim strBeginDate as String = Request.Form.GetValues("date")­(0)
Dim strBeginTime as String = Request.Form.GetValues("sTime")­(0)
Dim strTotalBegin as String = strBeginDate + strBeginTime
Dim beginDateas Date = DateTime.Parse(strTotalBegin)


writer.WriteLine("DTSTART:" &
beginDate.ToUniversalTime.ToSt­ring("yyyyMMdd\THHmmss\Z") )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,131
Latest member
IsiahLiebe
Top