Solved

How to read DataGridView to String Variable seperating each field with a Tab character

Posted on 2006-11-13
1
369 Views
Last Modified: 2008-01-09
I am using the DataGridView to allow users to enter a variable amount of information from an Access DB.  At the end of the application it sends an e-mail with other form data but I would also like the contents of the data grid to be included in the e-mail.  The e-mail is working with form field based content but the dataset/datagrid view is new.

How would you store the contents of the DataGridView into a String variable with the following formatting?

- Each field value seperated with a tab
- If the DataGridView dataset has no rows then the value of the entire string variable should be N/A.

Example (Dataset has data):
Field1      Field2      Field3      Field4
Field1      Field2      Field3      Field4
Field1      Field2      Field3      Field4
Field1      Field2      Field3      Field4

Example (Dataset has no data):
N/A


The Datagridview is named datagridTransport
0
Comment
Question by:endrec
1 Comment
 
LVL 10

Accepted Solution

by:
gangwisch earned 500 total points
ID: 17931912
dim EmailText as string="Hello this is a test email" & vbcrlf
for r as integer=0 to datagridview1.rows.count-1
dim CurRowStr as string=""
for c as integer=0 to datagridview1.columns.count-1
CurRowStr &= datagridview1.item(c,r).value & chr(9)
next
EmailText &=CurRowStr & vbcrlf
next
if datagridview1.rows.count=0 then
EmailText &="N/A"
end if
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now