|
I want to exit a for each loop early. How do I do that.
Here is my loop? Some code from inside the loop is missing.
For Each row As DataRow In dtGetLid.Rows
dtCkLessStat.Clear()
Call checkLessonStatus(Convert.ToInt32(row("less_id")), dtpText)
Next
Can I put it in a function and then exit the function when the loop finds a particular condition?
How do I exit the function?
|
|
|
|
|
In C#, you put the break keyword to exist a loop. Not sure if it works for foreach, or if the syntax is the same in VB. I wouldn't use foreach unless I intended to iterate over them all. I'd use a for loop for that, or better yet, a while loop that can be set up to break naturally, without a break statement inside the loop.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
The break keyword does not work in VB.NET. Would it work to clear the dataTable?
|
|
|
|
|
Then there is probably another word in VB. However, a while loop is the nicest solution.
Would what work ? The break keyword won't cleay anything, and any sort of loop is going to run the code inside the loop.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am not sure, but if I understand your problem you just need something to exit FOR loop.
You can use Exit For for this.
"Legacy code" often differs from its suggested alternative by actually working and scaling.
—Bjarne Stroustrup
|
|
|
|
|
hi
how i can display the relation betwwen tables in the datagridview control;
|
|
|
|
|
I have a VB.NET VS2008 windows form application where I have a crystalviewer form setup to print a few reports out from the menu off of the main data entry form.
The crystal reports are already written and stored in a folder on one of our servers (For this example lets call it \\MyServer\ReportFolder\). The crystal report uses a DSN to know where to find the data (For this example lets call it MyCrystalDSN).
The code on the menu fires off the report as shown below:
Dim frmCV As New frmCrystalViewer
frmCV.CrystalReportViewer1.ReportSource = "\\MyServer\ReportFolder\Reportname.rpt"
frmCV.WindowState = FormWindowState.Maximized
frmCV.ShowDialog()
Ok, everything works great for now, but of course it never fails that when you develop at your desk with all the rights available as a developer it all works and when you deploy the app, everything never works as planned.
When I publish the project for use by the client, I have to setup a DSN so the Crystal Reports will work.
Can I do this on the fly with code? For example, my crystal reports are using the MyCrystalDSN, and I don't want to have to remember to setup a DSN for everyone's computer I deploy the application on. Can I code the DSN information to use in the code prior to firing off the report?
A coworker gave me the following code from an article that I believe was written in 2001 for VB6. Is anyone doing this in .NET? Here is that code:
Public Sub RegisterDatabaseSample()
'Create a DSN called TEST on a server called ThatServer
DBEngine.RegisterDatabase "TEST", "SQL Server", True, _
"Database=pubs" & _
vbCr & "Description=Sample DSN" & _
vbCr & "Server=ThatServer"
End Sub
Any help is appreciated
Lost in the vast sea of .NET
|
|
|
|
|
I've been searching for the solution on the web and found a few different suggestions which I combined and came up with the answer to my question.
Here is the code:
Public Declare Auto Function SQLConfigDataSource Lib "ODBCCP32.DLL" _<br />
(ByVal hwndParent As Integer, ByVal fRequest As Integer, _<br />
ByVal lpszDriver As String, ByVal lpszAttributes As String) As Integer<br />
<br />
Private Const ODBC_ADD_SYS_DSN As Integer = 4<br />
<br />
<br />
Private Sub Create_DSN_For_Crystal_Reports()<br />
Try<br />
Dim attributes As New System.Text.StringBuilder()<br />
Dim returnCode As Integer<br />
<br />
attributes.Append("DSN=MyCrystalDSN")<br />
attributes.Append(Chr(0))<br />
attributes.Append("Server=MyDBServer")<br />
attributes.Append(Chr(0))<br />
attributes.Append("Description=DSN added via code from My VB App")<br />
attributes.Append(Chr(0))<br />
attributes.Append("Database=MyDatabase")<br />
attributes.Append(Chr(0))<br />
attributes.Append("AnsiNPW=Yes")<br />
attributes.Append(Chr(0))<br />
attributes.Append("QuotedId=Yes")<br />
attributes.Append(Chr(0))<br />
attributes.Append("Trusted_Connection=Yes")<br />
attributes.Append(Chr(0))<br />
attributes.Append(Chr(0))<br />
<br />
returnCode = SQLConfigDataSource(0&, ODBC_ADD_SYS_DSN, "SQL Server", attributes.ToString)<br />
<br />
If returnCode <> 1 Then<br />
Throw New Exception("DSN could not be setup to allow Crystal Reports access")<br />
End If<br />
Catch ex as Exception<br />
msgbox(ex.message)<br />
End Try<br />
End Sub
Hopefully posting the answer will help someone else later who has the same problem.
Lost in the vast sea of .NET
modified on Thursday, March 6, 2008 8:45 AM
|
|
|
|
|
You can create a typed dataset, get the data yourself via ADO.net and then supply the report with the loaded type dataset and then you don't need a DSN for Crystal. A developer I work with has used this technique in the past. I haven't tried it yet.
http://support.microsoft.com/kb/320714
http://www.gridviewguy.com/ArticleDetails.aspx?articleID=201_Creating_Crystal_Reports_Using_Typed_DataSet
|
|
|
|
|
Thanks for the feedback. I'm actually using the technique you suggested in several other projects and yes it works great. With the project I'm currently working on, they want me to fire off already created Crystal Reports from my VB application which uses a preset DSN.
Thanks again for you response!
Lost in the vast sea of .NET
|
|
|
|
|
Oh I see - yeah, that's too bad - that's our current situation too - forced to use the DSN way due to the reports being developed that way. I'm too lazy to look into it, but perhaps with the Developer edition of CR someone could modify the data source part on the fly and convert it to accept data through a typed set instead of DSN's.
|
|
|
|
|
Hi all!
I have a question:
It's possible to reading all data received from port 80 (HTTP) in VB.NET?
I have tried but without success
Thanks, and sorry for my bad English
|
|
|
|
|
Hi,
I'm using VB6 with Crystal Reports 8.5 ActiveX Designer Run Time Library
I am trying to add a new section to the report at runtime.
I'm using the following code:
(CRXReport is defined as: CRAXDRT.Report)
<br />
Dim CrSection As CRAXDRT.Section<br />
Set CrSection = CRXReport.Sections.Add()<br />
I get the "Invalid procedure call or argument" error, I also get it when I use:
<br />
Set CrSection = CRXReport.Sections.Add(index)
When I just get an existing section it works
<br />
Set CrSection = CRXReport.Sections(index)<br />
Any ideas why this isn't working and how to solve this?
thanks.
|
|
|
|
|
Hi,
I am working on a vb.net app in which i need to use the transparency key property. Yet, all of a sudden, i cant get it to work. I have a panel on a mdi child form. I have set the righttoleftlayout property to false and also set the resolution of my screen to 16 bit (as the microsoft site says there is a bug with depth over 24 bit). I even tried putting the panel in the mdiparent and fiddling around with the colours and setting the parent's righttoleft property to false. It still doesnt work. Any ideas?
Thanks,
Ahmad
|
|
|
|
|
can you tell what you want to transparent, i mean is it image or the control ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hi All,
I am trying to find out a way to copy all the files that are in a folder and its subfolders (a folder tree) into a single folder (so all files are in the same folder. In other words I am trying to consolidate all files from a tree of folders into a single folder with no subfolders). If the file already exists in the target folder, the code should add a progressive number to the file name.
Thanks in advance,
Regards, Krishnaraj
|
|
|
|
|
|
I am getting a timeout expired in vb.net with sql application.
|
|
|
|
|
Any specific query type or nature of connectivity; a few additional details could help expedite a solution to the problem.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
I am using a webbrowser control to load and show supported documents within it. for file types that it cannot embed, i want to automatically launch the application that is associated with that file and open it there. How can I solve the following problems
1. When I enter the following code line
myWebBrowser.Navigate("C:\myFile.xls")
How do i avoid the download dialog from popping up?
2. How can i tell if my webbrowser will not be able to embed this application but will be able to embed that one?
3. In which event of the WebBrowser control do i need to do this?
Thanks for your assistance.
|
|
|
|
|
I don't think you can. It is for security reasons since the user should be aware of the nature and type of files coming into his system.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
Thanks for your reply.
Ok, or maybe how do I cancel the download completely wen it is about to happen and initiate another process. Note I jus wanna cancel the download if it is going to make that download diolog box pop up otherwise if the browser can embed the document, i want it to continue.
|
|
|
|
|
I got a Project to make an Windows Explorer style Form to brows files and folders. Now i m just checking out the result of the code as below,
=============== My CODE ============================
Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
'On Error Resume Next
Try
searchResults = My.Computer.FileSystem.GetFiles(directory, FileIO.SearchOption.SearchAllSubDirectories, wildCards)
'UnauthorizedAccessException
Catch ex As UnauthorizedAccessException
'MessageBox.Show(ex.Message)
End Try
End Sub
================ end here ====================
this code throws the following exceptions of "UnauthorizedAccessException"
But i want to search through all the directories and subdirectories. If there some files or subdirectories where there is no user access allowed i want to continue searching bypassing that directory or subdirectory.
So that i could make a complete search of files and folders and make that Explorer Style interface.
Thanks
|
|
|
|
|
the only thing i could find for this is a impersonation of the system user....
but it doesnt sound like it should be done that way (and on top of that, i havent figured it out how to use that)
|
|
|
|
|
Hi
I’m using vb.net to create an xml file based on an xsd file.
I can create the file, except for the header
The file I’m trying to create needs to begin:
- <datafeed_response xmlns="http://www.moneycardltd.com/v2.5/datafeed_response" version="2.5">
- <cards>
Whereas using the xsd file to create this results in:
<cards>
<datafeedrequest xmlns="http://www.moneycardltd.com/v2.5/datafeed_request">
<datafeed_request version="2.5">
<cards>
The code I’m using to generate this is:
With myXmlDataDocument
'datafeed_request
xmlDataRow = .DataSet.Tables("datafeed_request").Rows.Add()
xmlDataRow.Item("version") = "2.5"
'cards
xmlDataTable1 = .DataSet.Tables("cards")
xmlDataTable1.Rows.Add()
Any help, is much appreciated.
|
|
|
|