473,324 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Code in one line

Hello,

I have created an email message:
Dim email As New System.Net.Mail.MailMessage

Is it possible to make the following code in one code line (here ***):

Dim emailCollection As New System.Net.Mail.MailAddressCollection
Dim emailAddress As Net.Mail.MailAddress

emailAddress = New Net.Mail.MailAddress("sd", "sd")
emailCollection.Add(emailAddress)
email.To = emailCollection ***

Thanks,
Miguel

Oct 10 '06 #1
2 1891
I now reduced to less lines:

Dim emailCollection As New System.Net.Mail.MailAddressCollection

emailCollection.Add(New Net.Mail.MailAddress("sd", "sd") )
email.To = emailCollection

I also tried the following:

email.To = New System.Net.Mail.MailAddressCollection.Add(New
Net.Mail.MailAddress("sd", "sd") )

This is what I was trying to no but no success.

Thanks,

Miguel

shapper wrote:
Hello,

I have created an email message:
Dim email As New System.Net.Mail.MailMessage

Is it possible to make the following code in one code line (here ***):

Dim emailCollection As New System.Net.Mail.MailAddressCollection
Dim emailAddress As Net.Mail.MailAddress

emailAddress = New Net.Mail.MailAddress("sd", "sd")
emailCollection.Add(emailAddress)
email.To = emailCollection ***

Thanks,
Miguel
Oct 10 '06 #2
2 lines is probably the shortest you can make it (untested code alert):

email.To = New System.Net.Mail.MailAddressCollection()
CType(email.To, System.Net.Mail.MailAddressCollection).Add(New
Net.Mail.MailAddress("sd", "sd") )
But I think its better to keep it as 4 or 5 because it is much more
readable.
Getting it down to 1 line is kind of pointless. Maintainability is much
more important than any slight performance benefit you *might* get.

Steven

Oct 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike Fisher | last post by:
I'm seeing an error when I try to run/debug a web service. Although it doesn't happen every time, it does occur more than half of the times I hit F5. It appears to be returned by the the JIT...
22
by: Illya Havsiyevych | last post by:
Hello How easily parse VB/VBA code by VB/VBA code ? Is any ready solutions ? Thank's, illya
1
by: None | last post by:
Hello all, I have a 97 database that I have been trying to consolidate code. Most of my forms use visual aids for the user to guide them along with the data entry. For example, I will make the...
65
by: Skybuck Flying | last post by:
Hi, I needed a method to determine if a point was on a line segment in 2D. So I googled for some help and so far I have evaluated two methods. The first method was only a formula, the second...
3
by: Hamilton | last post by:
Hi there, I've seen this error appear a few times in newsgroups but unfortunately I haven't found one that actually provides a solution. I'm basically deploying a new website into an area at a...
1
by: Razzie | last post by:
Hi all, I was working on a little project, worked fine, but now all of a sudden I get: The compiler failed with error code -1073741502 as an error message (when running the site, not...
9
by: Eric Lindsay | last post by:
I can't figure how to best display little snippets of shell script using <pre>. I just got around to organising to bulk validate some of my web pages, and one of the problems occurs with Bash...
18
by: vermarajeev | last post by:
Hello everybody, This is my second query in this post. Firstly thankx to Banfa, for helping me solve my first query. Here is the code which I have written. #include<iostream>...
1
by: bhanupoornakumar | last post by:
Hi .. when i am setting a website i am getting the following error.. The compiler failed with error code -1073741819. This is the full error .. u can see below. Compilation Error ...
19
by: Pavan | last post by:
Hi, I want to know if there is any software for measuring lines of code of my c++ application. I found out a tool, sloccount, but it gives only physical lines of code. I found out one more...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.