I have a tricky piece of code in C# that I need translated to VB.NET. That's not usually a problem, as I can do it by hand or using one of the many conversion websites. However, this particular piece of code uses the Yield keyword; and I don't know how to work around that. [Code]
Note that I'm aware of other yield in vb.net questions here on SO. I'm playing around with Caliburn lately. Bunch of great stuff there, including co-routines implementation.
Most of the work I'm doing is C# based, but now I'm also creating an architecture guideline for a VB.NET only shop, based on Rob's small MVVM framework.Everything looks very well except using co-routines from VB. Since VB 10 is used, we can try something like Bill McCarthy's suggestion:
[Code]...
It definitely isn't as elegant as C# version, but it looks to be doable. We'll see if there are any problems with this. If anyone has better idea, I'm all ears.
the name pretty much says it all, I need a more reliable code then AppActivate that does the same thing. I need it to activate a program I tell it to, perferribly without calling the process id.
What would be an cleaner alternative for a code like this.
Dim dAdapter As New SqlCeDataAdapter dAdapter = New SqlCeDataAdapter("SELECT name FROM Users WHERE username='" & GlobalVars.user & "' AND category = '1'", ConnectionString)
First off let me say that I am essentially new to VB.NET, i.e; still learning. Also, I hope that this is the right place to post this question. In a Project I have a Class module defined as:
Public Class Def Public Id As String Public Meaning As String
I am Using Visual Basic 2010 Express. And the Express Version Does Not have a MicrosoftReportViewer Facility. But is there an Alternative that can be used. I know Monies have to be made But Surely there should be an alternative For the Microsoft Visual Studio/Basic 2010/2008 Express User.or is there another way to create a reportViewer in Visual Studio/Basic 2010 Express. I have Downloaded the MicrosoftReportViewer Redistributable from
[URL]
and I run the setup but it does not work. I know there are other apps that might help me like crystal report. But I want to just use Microsoft version as it is a Microsoft Program.
I am enrolled in a college course using Visual Basic 2010 Express.My current assignment calls for the following:Create a small program that allows a user to enter the total amount of purchases for the purpose of calculating rewards points based on the purchase totals vs. their membership level of basic, standard and premium.The user selects their membership level via 3 radio buttons, basic, standard or premium.
The total of purchases and their rewards points depend on the membership level. Example, if you are a basic customer and your total purchase is under $75, you receive 5% in rewards points (70 x 0.95). Additionally, if the total is between $75 and $149.99, you receive 7.5% rewards.Here is what I have so far, but I am getting errors on the ElseIf statements:
If basicRadioButton.Checked = True And totalTextBox.Text < 75 Then rewards = total * 0.95 ElseIf basicRadioButton.Checked = True And totalTextBox.Text > 74 AndAlso totalTextBox.Text < 149.99 then rewards = total * 0.925 ElseIf basicRadioButton.Checked = True And totalTextBox.Text > 150 Then rewards = total * 0.9
I am currently using the registry to get file descriptions for files. As an example, so that a DOCX file will return the description "Microsoft Word". I am doing this from the HKEY_CLASSES_ROOT registry key.However, registry access is extremely slow, and I need to do several thousands of these. Is there an alternative way to do this?
The only way I can think of to display this moustache is by creating a new form and locking it to a certain point, that all works.My problem is with all the events surrounding this. E.g. minimizing the actual application etc...I know how to handle those in code but that is painstaking as I have to think of every possible event which would result in a problem then manually code for the moustaches relative actions. So, I would like to know:
I want a custom menu when I right click. Like, you know when you right click on your desktop, and you see a bunch of menus, like properties and whatnot. How do I do that with VB.Net? Also, how to add custom?
I'm trying to make the combobox get suggested values from a website using the current keyword they have in the box already. For example if I have O, it will show up values that the website has returned with O. The problem is how can I make it work where whatever I type into the combobox, it will get the values, set the datasource and make it show up. So far I have this:The problem is whenever I type something, I cannot get it to set it to the new datasource without the comboxbox becoming the first value in the data source.
Dim pop As New List(Of String) pop.Add("Koolaid") pop.Add("kIMKY") pop.Add("KoolPaid") ComboBox1.DataSource = New BindingSource(pop, Nothing)
What is the difference in the two blocks of code below? I expected them to return the same result, but they don't.
In the case where xml.@Type = "null", I want PatientMetricTypeID (a nullable Integer) to end up being Nothing.
Block #1: If()
In this case, it ends up as 0. It looks like Nothing is being treated as an Integer and converted to 0. I can sort of see why this might happen but not fully... I would like to understand exactly how this works, and if there is a workaround.
Dim PatientMetricTypeID As Integer? = If(xml.@Type = "null", Nothing, CType([Enum].Parse(GetType(PatientMetricTypes), xml.@Type), Integer))
Block #2: If
In this case, it ends up as Nothing -- expected behavior.
I have the following code below which has an error. When the checkbox is set to true and for example change the "role", and click save the following error is given;
"Index was outside the bonds of the array".
I know the reason of the error but don't know the solution..
The TxtPayCont is a concatenation of title, fname, and lname in an array. Therefore, if all the fields have values, then it works fine. So if it is Mr Jones Tim, this works, but, if it is Mr Jones it does not. It has to have 2 spaces to work. Is there anyway round this...
In C#, when writing a function that returns an IEnumerble<>, you can use yield return to return a single item of the enumeration and yield break; to signify no remaining items. What is the VB.NET syntax for doing the same thing?
What is the best way to resize & move a form using just VB commands? I have a form that I need to set the Height and Top props, problem is that takes two calls and there is a noticable flicker. I tried using SuspendLayout/ResumeLayout, DoubleBuffered, swaping the top and height calls around, etc, but nothing seems to help. The test forms only have one small listview and one or two buttons. [Code]
this is essentially the code in a class module I added to the project.
Module CFKMod Public Maps(5) as Map Public Class Map Public Tiles(7, 7) As Tile
[code]....
The problem is this: NullRefereceException was unhandled - Use the "new" keyword to create an object instance.So I've tried placing the word "new" in various locations in front of references to any picturebox to no avail. I even tried to add this before the ** line:
Maps(1).Tiles(1, 1).pctrbox = New PictureBox
In which case the same error moves up to that new line instead. That seems entirely baffling, because VB is telling me that I need a "new" keyword when it is clearly there. I expect either it is in the wrong spot or I'm declaring something incorrectly.
I am using a .Net JavaScript implementation called Jurassic to run user-controlled scripts within my .Net 4 WPF application coded in VB.Net - C# answers are fine. The script engine runs on its own thread and provides an API for the script to interact with my application. This all works really nicely until a user executes a script that causes an infinite loop and takes out a core of the processor.
[Code]...
The reason I care about keeping the thread alive is because the user who wrote the script and the user who is running it may not be the same, and I want to keep the experience as smooth as possible the the user running the thread. There also might be legitimate situations in which a single JavaScript function would run for a long time and I do not want to kill that, I just want to stop being allowed to hog the resources.
Solutions that involve stopping the thread from slowing down the system but that still show high CPU usage are not preferable because I do not want the user to wrongly feel that the application is resource intensive.
I have two classes, one nested in the other. [code]Neither "Name" or "ID" are unique between operations and records.I wish to construct a dictionary using LINQ = Dictionary(Of String, Of List(Of Integer), whereby the keys are uniqe examples of Names in my collection and the values are the collective set of distinct IDs that are associated with those names.
I am converting C# program to VB. I heard that "Yield" statement is ready from Visual Studio 2010 SP1.
[URL]
I updated my developing environment to Visual Studio 2010 SP1. However IDE still displays error to the following code saying that "yield" is not delclared.
Public Class WeakCollection(Of T)
Implements IEnumerable(Of T)...
ReadOnly innerList As List(Of WeakReference) = New List(Of WeakReference)()
I've created an app (VB.NET) where each installation of the app works with a single local database on the PC. No multiuser and no ability for the user to change databases - the database is effectively part of the app, with a fixed scema, only the data will change.At the moment the database is SQL CE. It has about 30 tables with some simple relationships between the tables.
I'm wondering if there is an alternative to SQL CE that might be faster in this scenario. Although SQL CE is excellent and easy to use, I get the feeling there is perhaps an unecessary overhead when using it for something simple - and it does seem a little slow when my app is doing complex stuff that interacts a lot with the DB. In my prototype I actually loaded the 'database' tables from text files into Arrays and developed subs and functions to perform the database searches etc. It was blindingly fast but I realised it wasn't a scaleable solution because it was an 'in-memory' database. A compromise would be to 'page' data into array when needed, but it all gets horribly complex and that's probably why some very clver people have created SQL CE !
Using VB.net, I have a namespace which I'd like to rename for the future. However, I'd also like to keep the old obsolete namespace for a time to ensure backward-compatibility for our consumers for awhile. Is there a way in .NET to have two namespaces, one ordinary and one that merely is an alternative name for the other?
Below is the code for a linked list search I have tried to implement in to searching through each of the elements of htmlelements .For some reason If element.InnerText = (item) will only work if if is only a string ("example") .Are there any other ways of Implementing the for each loop to search through my item linked list?
Original code for searching for 1 string
Private Sub block() Dim elements As HtmlElementCollection = webBrowser.document.All Dim word_found As Boolean word_found = False
[CODE]...
This is the Loop for item I have tried to implement but is not working ,because of the for each loop .The value of element.Innertext = "" or null when I try to use one of the linked list item[If element.InnerText = (item)] is used and only have a value when a string is used to [If element.InnerText = (google)]
Private Sub block() Dim elements As HtmlElementCollection = webBrowser.document.All Dim word_found As Boolean word_found = False Dim item As LinkedListItem = words.Head