|
Dave Kreskowiak wrote: It's actually faster than if you put "STAT = 0" in the same spot and put the Dim outside the loop.
You are comparing code that is not equivalent. The variable is initalised to zero only once, regardless of where in the code it's declared. Where the Dim statement is placed only affects the scope of the variable, the generated code is exactly the same regardless if the variable is declared inside or outside the loop.
Example:
Dim s As String = String.Empty
For i As Integer = 1 To 5
Dim x As Integer
If i = 3 Then x = 1
Console.WriteLine("{0}: {1}", i, x)
Next
The output:
1: 0
2: 0
3: 1
4: 1
5: 1
As you see, the variable x is initialised to zero eventhough it's not assigned any value until the third iteration in the loop. Once it's assigned a new value, it retains the value for the remaining iterations, demonstrating that the variable is never re-initialised.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Crap. The effects of getting 4 hours of sleep a night for the last 2 months...
|
|
|
|
|
Hi Friends..
I need to bind the dataset return value to excel.The thing is ..if i bind to a datagrid and then if i import to excel it works..But what i need is to bind the dataset directly to excel without the intervention of datagrid..Someone help in this regard as early as possible.
Thanks In Advance..
Balaguru
|
|
|
|
|
You can't bind an Excel worksheet directly to a DataTable in .NET. Excel doesn't know anything about .NET classes so can't directly interface with them. You'd have to build the worksheet cell-by-cell from the DataTable. You can checkout this[^] and this[^] for examples.
|
|
|
|
|
Hi all,
How can use the IN Operator with Parameters. Any Example will be helpfull
Thanks
Dana
|
|
|
|
|
Hello Dana,
The values that do not fit into a neat range, we use the IN operator. An example would be:
Select * from Customers
Where CustID IN (1, 3, 5);
The above query will give us rows for CustID 1, 3 and 5 from the Customer's table.
Regards,
Dave
Dave Traister
Software Engineer
ComponentOne LLC
www.ComponentOne.com
|
|
|
|
|
Thanks for the post Dave Traister,
How can I implement this using Sqlcomamnd.Parameters object
Regards,
Dana
|
|
|
|
|
Hello Dana,
Try the following:
Dim commandText As String = _
"Select * from Customers
Where CustID IN ( @ID);"
command.Parameters.Add("@ID", SqlDbType.Int)
command.Parameters("@ID").Value = customerID
Dim rowsAffected As Integer = command.ExecuteNonQuery()
The link below shall give you more information but it does not use the IN operator:
http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.parameters.aspx
Regards,
Dave
Dave Traister
Software Engineer
ComponentOne LLC
www.ComponentOne.com
|
|
|
|
|
Hi,
I am customizing the datagrid view columns in windows application.That is not successful to me.How to generate particular table values in the datagrid view control in customizing manner.
Regards,
vidyashankar.T
|
|
|
|
|
You didn't say what you're having a problem with. Are you creating your own DataGridViewColumn implementation from scratch?? Are you inheriting from another DGVCOlumn type?? Did you create a custom editing control for this column type??
What you're asking is way too large of a topic for a direct answer in a forum post. Given the vague scope of your question, this[^] is about the best information you can get.
|
|
|
|
|
Hi,
I have a Async socket receiving app and a sending app, the receiving app works great. The problem is when i'm sending something with the sending app ( begin connect -> endConnect, BeginSend - >EndSend) The begin send callback which on the first line does:
private sub beginSendCallback(byval ar as iAsyncResult)
socket.endsend(ar)
end sub
' This callback method is called in a matter of seconds, but the 'file has about 3-4 MB, and the sending isn't near to completion, I have a list of IP addresses in which to send the file, but because the sending to the first IP address isn't finished, although the callback method is called it moves on, and of course creates an error later in the program...
So how do I stop the callback method from calling itself until the file transfer is complete, or how to somehow know when the file is completely transferred.
Thank you!
|
|
|
|
|
I added the line of code option strict on to my program and I noticed that I got a lot of errors about not being able to convert from decimal to double, etc.
When should I use option strict on?
|
|
|
|
|
Hi,
Visual Basic allows conversions of many data types to other data types. Data loss can occur when the value of one data type is converted to a data type with less precision or smaller capacity. A run-time error occurs if such a narrowing conversion fails. Option Strict ensures compile-time notification of these narrowing conversions so they can be avoided.
In addition to disallowing implicit narrowing conversions, Option Strict generates an error for late binding. An object is late bound when it is assigned to a variable that is declared to be of type Object.
Because Option Strict On provides strong typing, prevents unintended type conversions with data loss, disallows late binding, and improves performance, its use is strongly recommended.
In other words, Option Strict restricts implicit data type conversions to only widening conversions. Widening conversions explicitly do not permit any data type conversions in which data loss may occur and any conversion between numeric types and strings.
I hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Given an array of byte, what's the best way to convert it to something like an array of signed short (taking two bytes per value)? In C, it's possible to do something like "*shortptr = (short)(ptr[0] + (ptr[1] << 8));" and have the compiler silently handle the fold-over of 32768..65535 to -32768..-1; no muss no fuss. Is there any practical alternative to something like "shortvar = bytes[i] + ((bytes[i+1] and 127)-(bytes[i+1] and 128))*256"? That extra masking step seems excessively clunky.
|
|
|
|
|
Don't ask a completely unrelated question as a reply to a thread that someone else created. Start a new thread.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi codeprojecters...i am beginer in C++ environment ...i want to improve my knowledge ..how to improve my skil..i need ..ur Answers
*****THANKS N ADVANCE****
Mathen.K
(I WILL TRY MY LEVEL BEST )
|
|
|
|
|
Well, one of the first things that you should learn about C++ is that it's not Visual Basic. This will help you post in the right forum the next time...
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
i create small project but i'm found
some problems when i try to convert ascii to hex using VB 6.
could you help me to give me some example code ?
i want to convert string "0c331760280703000112"
Thank you in advance very much for your kind help
|
|
|
|
|
What do you mean by ASCI to hex ? That is a hex string, and it looks too big to turn into an int.
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 )
|
|
|
|
|
Do you mean that you want the result "3043333331373630323830373033303030313132"?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
The following code properly replaces the node's text property with the value from the form. However, I need to replace the CDATA section of the node. What would be the proper syntax to accomplish this in VBScript?
Set objXMLDoc = Server.CreateObject("MSXML2.DOMDocument")
objXMLDoc.async = false
objXMLDoc.loadXML(sAttribute_data)
Set NodeList = objXMLDoc.getElementsByTagName("*")
For Each Elem In NodeList
If Elem.tagName = "comment" Then
Elem.Text = Request.Form("txtcomment")
End If
Next
|
|
|
|
|
Working on first web dev site in VWD 08. I can get the FormViw control to sync w/ GridView control using the code below and ONLY for the first 10 records. When I click the pager link to page 2, I can't get the next batch of records to display in FormView, it stops at 10.
What Gives?
Question:
What code or property setting will make this function work?
Current Code:
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
FormView1.PageIndex = GridView1.SelectedIndex()
End Sub
|
|
|
|
|
Then you should ask in the ASP.NET forum.
The best way to do paging is to request the page you want from your source, auto paging will fill viewstate with all the records. My guess is that you're binding to your data source every time, which will reset the data source to page 1. Have you set a break point to see if this code is run ? What's the other code look like ?
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 )
|
|
|
|
|
Hi Christian,
Sorry about the muliple posts, this' my first time on the site and I wasn't sure of being in the right forum.
As I indicated, I'm new meat to web dev, currently on ch. 10 of 19 in my Beginner VB05EE book(Peter Wright's Novice to Pro -Apress). I downloaded VWD 05 & 08 about a two weeks ago and got stuck on this problem. I thought that the book would walk me throuh it, but it only left me with a beginners insight, so Im unable to follow your reply.
As for the other code, well there is none. I basically C&P'd something I came across while viewing the video tutorial that came w/ VWD05. Although, are you asking for the VB code, or the asp code?
I've tried several variations on the above code, I even attempted an If statement, however I fumbled miserably.
What ever you can offer would be appreciated.
Thanks in advance.
Arman
|
|
|
|
|
Thanks in advance for any help with my problem. I don't think it is too complicated but I have been unable to figure it out after many hours. I have a program that needs to play an endless loop of different videos, it uses Direct X and plays them in a panel on the form. The problem is as the program runs every new video the memory for the process increases in size until eventually there is an error. I believe that this is because I am never disposing of the video when it is done but when I leave this method and come back after the video is done i do not know how to access the old video to dispose before it opens the next. Here is the related code.
Private Sub OpenMovie(ByVal FileLocation As String)
Dim Height As Integer = VideoAd.Height
Dim Width As Integer = VideoAd.Width
Dim AdVideo As New Microsoft.DirectX.AudioVideoPlayback.Video(FileLocation)
AdVideo.Owner = VideoAd
VideoTimeLeft = Advideo.Duration
Advideo.Play()
Advideo.Audio.Volume = -5000
SecondTimer.Start()
VideoAd.Height = Height
VideoAd.Width = Width
'Advideo.Dispose()
End Sub
VideoAd is a panel
and SecondTimer is the timer that monitors when the video is done playing.
- Richard
|
|
|
|