|
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
|
|
|
|
|
http://www.codeproject.com/KB/directx/DirectX9_media_playback.aspx[^]
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 trying to insert data into the table and teamID is the foreign key in the Participant table. I get an error essentially indicating that String (TeamName) cannot be converted to Integer (TeamID).
Here is the code...
'Form_Load event
Try
'Create an instance of the data-tier component (GymnasticsMeetData)
Dim teamData As New Data.GymnasticsMeetData
'Retrieve the dataset from the data-tier
Dim TeamDataSet As GymnasticsDataSet
TeamDataSet = teamData.getTeamDataSet
'Set up the binding source
Dim tBindingSource As New BindingSource
With tBindingSource
.DataSource = TeamDataSet
.DataMember = "Team"
.Sort = "TeamID"
End With
'Fill the combobox
With Me
With .teamComboBox
.DataSource = tBindingSource
.DisplayMember = "TeamName"
.ValueMember = "TeamID"
.DataBindings.Add("text", tBindingSource, "TeamName", True, DataSourceUpdateMode.OnValidation)
End With
End With
'UpdateButton_Click event
Dim gymClub As String
Try
gymClub = teamComboBox.ValueMember '(Tried teamComboBox.Text.. did not work)
Model.EnrollClass.GymnastAffiliation = gymClub
clubLabel.Visible = True
clubLabel.Text = gymClub
Catch ex As Exception
MessageBox.Show("String to Int: " & ex.Message)
End Try
'ADO for data access
Dim sqlConnection As SqlConnection = New SqlConnection("Data Source=lp1\sqlexpress;Initial Catalog=Gymnastics;Integrated Security=True")
Dim sqlCommand As SqlCommand
sqlCommand = New SqlCommand("addGymnast", sqlConnection)
sqlCommand.CommandType = CommandType.StoredProcedure
sqlConnection.Open()
Try
Dim sqlParameter3 As SqlParameter = New SqlParameter("@TeamID", SqlDbType.Int)
sqlCommand.Parameters.Add(sqlParameter3)
sqlParameter3.Value = gymClub '(Tried teamComboBox.ValueMember... did not work)
Catch ex As Exception
MessageBox.Show("String to Int: " & ex.Message)
End Try
Dim sqlParameter9 As SqlParameter = New SqlParameter("@RetVal", SqlDbType.Int)
sqlCommand.Parameters.Add(sqlParameter9)
sqlParameter9.Direction = ParameterDirection.Output
If sqlCommand.Parameters("@RetVal").Value > 0 Then
insertStatusLabel.Text = "Success!"
Else
insertStatusLabel.Text = "Failure"
End If
sqlCommand.ExecuteNonQuery()
sqlConnection.Close()
Private Sub teamComboBox_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles teamComboBox.SelectedValueChanged
Model.EnrollClass.GymnastAffiliation = (teamComboBox.Text)
End Sub
'In the Model Class
Private Shared m_affiliation As String
Public Shared Property GymnastAffiliation() As String
Get
Return m_affiliation
End Get
Set(ByVal value As String)
m_affiliation = value
End Set
End Property
|
|
|
|
|
It looks like that the problem is related just to the two types not being the same. I have some code that does the same thing figured I would post and see if it helps.
Dim SqlCommand As New System.Data.SqlClient.SqlCommand()
ErrorLbl.Text = ""
SqlCommand.Parameters.Add("@EventID", SqlDbType.Int)
SqlCommand.Parameters("@EventID").Value = EventSelect.SelectedValue.ToString
SqlCommand.Connection = SqlConn
SqlCommand.CommandText = "[DeleteEvent]"
SqlCommand.CommandType = CommandType.StoredProcedure
SqlConn.Open()
SqlCommand.ExecuteNonQuery()
Hope this helps
- Richard
|
|
|
|
|
Here is where I get an error message...
'Fill the combobox
With Me
With .teamComboBox
.DataSource = tBindingSource
.DisplayMember = "TeamName"
.ValueMember = "TeamID"
.DataBindings.Add("text", tBindingSource, "TeamName", True, DataSourceUpdateMode.OnValidation)
End With
End With
Not able to convert String ("TeamID") to Int32. It is reading the ValueMember,TeamID as a string, "TeamID". I am not sure if it is OK to use a parent table to populate the combobox, which is what I have done in this case. Team table is the parent of Participant table.
|
|
|
|
|
EventSelect.SelectedValue.ToString
SqlCommand.CommandText = "[DeleteEvent]"
Can you explain what EventSelect and [DeleteEvent] mean? Which event are you referring to?
Gymnast.
|
|
|
|
|
Hi everybody!
I'm developing a VB.NET 2005 application and I want to use a DataGridView, but I need to disable navigation, so I've been looking for a property like AllowNavigation (like the old DataGrid had) but I don't seem to find it. Is it that the Mycrosoft team removed this property for the new grid?
If somebody knows how I can achieve the same as AllowNavigation but for DataGridView, please, let me know.
Thanks in advance
Kenia
|
|
|
|
|
I've only worked with vb.net 2005...so what do you mean by disable navigation? Or what did the AllowNavigation property do?
|
|
|
|
|
What the property does is to allow the user to select whether to show or not links to child tables. If you know how to achieve this in the DataGridView control, please, let me know.
Thanks,
Kenia
|
|
|
|
|
Dear All,
I am new with VB coding, please help me with this problem.
I have a form including 1 input field, 1 dropdown menu and 1 submit button.
The scenario is:
If I dont move the mouse to the inputfield, and select a dropdown menu. It will automatically activate the submit button to update info. However, in this process, I want it ignore the data in the input field, and update only the item in the dropdown menu.
Could you please help me, i 'm being stuck in this issue for 2 weeks.
I would appreciate your time and your potential helps very much,
|
|
|
|
|
I used to have a good article saved in my favorites about this issue, but the link is no longer active. Here is another one I had saved:
http://weblogs.asp.net/Jeff/archive/2005/07/26/420618.aspx[^]
And you may find more about this by searching for the key words "ASP.NET Default Button" on google or CP.
Hope this helps.
|
|
|
|
|
Hi,
I have 2 proj-a user control project and a web page project(huge web site).
Currently using web deployment, I am creating a dll file for user control project. Then I am referencing this to web page project and build and debug to view the changes in web project.
To avoid this long process, I am trying to build a batch file to build both.
I am able to build the usercontrol using msbuild in the batch file.
Now I am not able to reference this dll file to webpage project and build the web page project using devenv.How do I reference dll file to webpage project in command prompt or in a batch file. Please help
|
|
|
|