Command(s) Replaced Type/End Type Statements ?
Oct 18, 2010In vb6 you could use:
Type SysInfo
Clr as Interger
Tmp as integer[code]...........
What command(s) do we use for structured varibles now?
In vb6 you could use:
Type SysInfo
Clr as Interger
Tmp as integer[code]...........
What command(s) do we use for structured varibles now?
I have the following code sample, where the only difference between the 2 parts of the If statement is the less than/greater than operators.Is there a better way to write this?Could almost do with being able to define an Operator variable.
If myVar = true Then
Do While (X < Y)
'the values of X and Y will change within this loop
[code].....
I would like to have a command prompt type interface on my form. The only thing I am aware of is a textbox, but there are no facilities to have commands and output scroll without keeping the entire history in a variable. That would be an ever increasing variable, which is ridiculous. Is there an alternate way to use a textbox as a command prompt, or is there something else I can do. Another note, is the use of an array. I know I can increase an array with commands, but this is no good either, because some responses in the box need to be paragraphs in length, so even a separate array for command and output is too cumbersome.
View 6 RepliesI'm helping a colleague develop a "catch all" type error handler for some controls his application. What he wants to do is pass the object that has the error, and the type of that object, such a TextBox or ComboBox, and then call the DirectCast method within his handler to properly address the Text attribute within it. In general, the method is looking like this:
Protected Sub SpecialErrorHandler(ByVal TargetControl As Object, ByVal ControlType As String)
MessageBox.Show("Bad Juice: " & DirectCast(TargetControl, ControlType(ObjType)).Text)
End Sub
So far any attempts to do a type conversion within the DirectCast method (since it is expecting an object in the general signature) or to even pass in the a Type object properly set is not working.
Any ideas here, or is this one of those "Casting doesn't work that way." type scenarios?
I am a beginning programmer and am having a problem with adding a record to a customer table in a Microsoft Access database. I have worked for hours reading my textbook and troubleshooting to no avail. When I execute this code below the record is not added and I do not get an error of any type. When I go into debug mode, all of the parameters are correct and everything looks good. If I open up Access I can manually add the record but using my program nothing happens. All datatypes are string in VS and text in Access.
First an instance of the Customer Class is created and this seems to be successful. But when I take that customer object and run the AddCustomer method of the customer class it is not successful in that the database does not reflect that the record was ever added. [Code]
Note: I'm using VB express 2008 I would mostly like to learn about the console application. Like how to make it type in a command and hit enter by itself. The project I'm working on is a booter for my iPod (Long story) I would like to be able to- 1- Either click a button on a form and have the console pop up and input
[Code]...
I've come from a Assembler and C/C++ background, so I understand the concept behind reference types versus value types in vb.net. Also, I've read Jon Skeet's article regarding references and value types and I understand all of that. My question is: How can you tell if a given type is a reference type or a value type? Is it simply that all integral types (ints, floats, etc.) are value types and all classes are reference types? (If so, where do strings fall?)
[Code]...
How would that work? I can't find any documentation in the MSDN.you know how when you open a txt file it opens up notepad and loads the file? how does the whole 'loading the file' thing work in VB?
View 1 RepliesI'm using VB.NET in Visual Studio 2008 in a Vista 64-bit OS. I'm trying to find an easy way (there must be one) to quickly retrieve from the registry the application file name and path to use in a Shell command to open a particular file. Specifically, I want the user in my app to be able to click on a PDF file and have the app open that PDF file using the application associated with PDF file types - Acrobat Reader, for example. Anyone have any suggestions as to proper coding & syntax for the following sequence?:
(1) Get name of .exe file associated with .pdf file type (most likely from the HKey Root Classes hive)
(2) Get path for the .exe file
(3) Shell("[pathname]appname.exe filename.pdf")
I've spent a couple of hours looking through the forums and haven't found what I'm looking for.
I have made a command line with arguments and i published it. But when i type in the command and press enter the but it closes the window.
View 3 RepliesI am using select command for one of my button
Dim edit1 As OleDbCommand = New OleDbCommand("select * from [exporter] where exp_id='" & t1.Text & "'", con1)
now:-
t1 is a textbox
and in my table exp_id is "Number" now when i run this i get an error at the time executing reader (Data type mismatch in criteria expression.) but when i change exp_id properties to "Text" it run's properly
when view in browser, i got this error: Unable to cast object of type 'ASP.webform1_aspx' to type 'System.Web.UI.WebControls.Button'.
how should i solve this problem?
Line 7: If Not Page.IsPostBack Then
Line 8: Dim rowIndex As Integer = 0
<b>Line 9: Dim btn As Button = DirectCast(sender, Button)</b>
[Code].....
I'm trying to add a new record to my database but i keep getting the message - "conversion from type DBnull to type string is not valid". I think its something to do with the Employee ID when VB attempts to save it to the database my code is below
Imports System.Data.OleDb
Public Class Add
Private Sub DisplayRow()
[Code]....
I now have SQL Parameters set up and I'm using them to save/delete/add my data. This all works well, except when it's trying to save a combobox to the datatable it appears with the error above.Majority of my comboboxes have datasources, and the valuemembers of these are the actual list items, not the ID's of the list items.I'm not sure why this error could be happening, I'm fairly sure I've connected everything to the binding source correctly; I've checked it a few times.Does anybody know what the cause of this could be? I've looked around a bit and I haven't found much
View 7 RepliesI've spent quite a bit of time reading up on generics, covariance, etc., and I am failing to understand why I get the aforementioned compiler error in this type of codeLet's say I have a base "Bill" class made up of a collection of Lines..
Public Class Bill(Of L As Line)
Private _lines As List(Of L)
Public Property Lines() As List(Of L)
[code].....
E.g. how do I get VB.Net to statically type a local variable to be the static type of the expression on the right had side of the assignment?
View 1 RepliesI had write code (just for learning), the codes :
dim Temp as string
Temp = Recordset("
Table_Field")
but, when I start Debugging the error messages "Unable to cast object of type 'ADODB.InternalField' to type 'System.String"
I am implementing IMAPI2 into my vb.net project but ran into a wall. I am getting the message Unable to cast object of type 'IMAPI2FS.FsiStreamClass' to type 'IMAPI2.IStream' when trying to start the burn. I googled around and found this is something that microsoft hasn't fixed.. which basically renders IMAPI2 useless in vb.net.
I found a post on codeproject.com by eric hadden who combined the IMAPI2.dll and IMAPI2fs.dll into an c# interop file. I also see the IBURN interop in microsoft SDK samples. I'd like to use either, but it's in c# and I'm using vb express. Does anyone know a way to get the interop into visual basic or a way around "Unable to cast object of type 'IMAPI2FS.FsiStreamClass' to type 'IMAPI2.IStream'"?
I'm having a problem with converting from one source type to a destination type. I have a form with 2 buttons (button 2 uses the OpenFileDialog to have the user open an excel file set to NewFile),(button 1 takes the contents from specific cells in NewFile and arranges them how I need into oXLApp1).
The error I get is "Unable to cast object of type 'System.IO.FileStream' to type 'Excel.Application'." in line 14 of the code below.
Public Class Form1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
[Code]....
I'm new to VB 2005, the code below is actualy coded from VB 6 and just converted it to VB 2005. I'm having trouble with line that's on bold letters.In VB 6 this works just ok. By the way the error message is "Unable to cast object of type 'System.String' to type 'ADODB.Connection'." [code]
View 5 RepliesI have a number of controls (Device1, Device2, etc.) that all inherit from BaseDeviceControl. In the DragEnter event handler I am trying to test for the correct type by using the BaseDevvceControl like this....
[Code]....
I'm compiling a VB.Net 2.0 app (created in VS2008) using msbuild, and now I've added a generic return type, it's giving me the following:
Warning: Type library exporter encountered a generic type instance in a signature. Generic code may not be exported to COM.
Having just spent ages removing all of the previous warnings, I don't really want to add a new one. Any idea how to get rid of it (aside from not using generics)?I don't know what details I'd put in the attribute, or what number to put in the project-level ignore list.
I am pulling data from a local MSSQL database using a stored procedure, then send the data to a web service. Every part of the component works well except for a pesky problem will a DBNull being returned from the DataRow field, when I know that the field is not null and has valid data. The database and associated INSERT statements that add to this field are designed to not allow NULL entries. When I debug break the program on or right before the line that throws the error I see that the field has valid data for the current row.If I add a null check to the code (as below) the operation continues as normal:
Dim dataResultsTable = Me.myViewTableAdapter.GetData(int)
For Each myDataRow In dataResultsTable.Rows
If worker.CancellationPending Then
[code]....
Why is the read operation returning DBNull instead of the data in the database?
EDIT: Just to be clear, the operation does return the proper data, but the data is not being saved into the variable.
I declare my dates as the following in my code:
Dim DeliveryDate as Date
But i am now trying to declare time however i keep getting an error because i cannot get the type correct. I tried the following but get the following error: "Conversion from type 'Timespan' to type 'integer' is not valid".
Dim DeliveryTime as DateTime
Dim DeliveryTime as Integer
In my database the DeliveryTime type is set to Time(7) so i would assume there should be 'Time' which i could use to declare it, but there isnt. What is the correct type i should be using?
Here is my exact code. There error is Input string was not in correct format:
GraphDate4 = String.Empty
DeliveryProducts = "{ name: 'DeliveryProducts', data: ["
If DataReader4.HasRows Then
[Code].....
I can't cast my objects. I get: "Unable to cast object of type 'ClassA' to type 'ClassB'".
The service Class:
Public Class svc_Insp
Implements Isvc_Insp
Public Function Test(ByVal pm_income As ClassC) As String Implements Isvc_Insp.Test
[code]....
I'm getting the error "Conversion from type 'DBNull' to type 'Date' is not valid."here's the line generating the error.
dtReady.Value = dSet.Tables("Db").Rows(Inc).Item("Fixed_Date")
I'm using a date/time picker control and sending the db value to it. I know that the value is null, but I don't understand why the Picker can't be blank. Is there a way to let it be blank? Or should I set up a way to check for nulls and assign today's date or something just in case?
I have these errors when creating my website?
Error 1Server Error in '/ Application. -------------------------------------------------------------------------------- Conversion from type 'DBNull' to type 'String' is not valid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: Conversion from type 'DBNull' to type 'String' is not valid. Source Error: Line 64:
Line 65:
I have a storedproc accepts parameters in XMLtype as
CREATE OR REPLACE PROCEDURE GetDetails(
p_para IN XMLTYPE,
[code].....
Could anyone assist me in solving my problem ? My code was written in VB (VS 2003.)I got this error: System.InvalidCastException: Cast from type 'DBNull' to type 'Integer' is not valid. in my code.Here is the code line where I am getting the error: LeadCampusID = CInt(.Item("mkCampusID"))I fixed the error by making the changes in the code as :
If Not IsDBNull(.Item("mkCampusID")) Then
LeadCampusID = CInt(.Item("mkCampusID"))
Else
[code].....
I have a Job Register Table and that table doesn't have any records.
This is my LINQ code:
Dim QRecordCount = (From LC In CntxtJobDetails.JobRegistrations _
Where LC.JobCode <> 0 _
[code].....