Search Results

Search found 4472 results on 179 pages for 'vb'.

Page 20/179 | < Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >

  • VB.NET switching from ADO.NET to LINQ

    - by Cj Anderson
    I'm VERY new to Linq. I have an application I wrote that is in VB.NET 2.0. Works great, but I'd like to switch this application to Linq. I use ADO.NET to load XML into a datatable. The XML file has about 90,000 records in it. I then use the Datatable.Select to perform searches against that Datatable. The search control is a free form textbox. So if the user types in terms it searches instantly. Any further terms that are typed in continue to restrict the results. So you can type in Bob, or type in Bob Barker. Or type in Bob Barker Price is Right. The more criteria typed in the more narrowed your result. I bind the results to a gridview. Moving forward what all do I need to do? From a high level, I assume I need to: 1) Go to Project Properties -- Advanced Compiler Settings and change the Target framework to 3.5 from 2.0. 2) Add the reference to System.XML.Linq, Add the Imports statement to the classes. So I'm not sure what the best approach is going forward after that. I assume I use XDocument.Load, then my search subroutine runs against the XDocument. Do I just do the standard Linq query for this sort of repeated search? Like so: var people = from phonebook in doc.Root.Elements("phonebook") where phonebook.Element("userid") = "whatever" select phonebook; Any tips on how to best implement?

    Read the article

  • VB.net httpwebrequest For loop hangs every 10 or so iterations

    - by user574632
    Hello, I am trying to loop through an array and perform an httpwebrequest in each iteration. The code seems to work, however it pauses for a while (eg alot longer than the set timeout. Tried setting that to 100 to check and it still pauses) after every 10 or so iterations, then carries on working. Here is what i have so far: For i As Integer = 0 To numberOfProxies - 1 Try 'create request to a proxyJudge php page using proxy Dim request As HttpWebRequest = HttpWebRequest.Create("http://www.pr0.net/deny/azenv.php") request.Proxy = New Net.WebProxy(proxies(i)) 'select the current proxie from the proxies array request.Timeout = 10000 'set timeout Dim response As HttpWebResponse = request.GetResponse() Dim sr As StreamReader = New StreamReader(response.GetResponseStream()) Dim pageSourceCode As String = sr.ReadToEnd() 'check the downloaded source for certain phrases, each identifies a type of proxy 'HTTP_X_FORWARDED_FOR identifies a transparent proxy If pageSourceCode.Contains("HTTP_X_FORWARDED_FOR") Then 'delegate method for cross thread safe UpdateListbox(ListBox3, proxies(i)) ElseIf pageSourceCode.Contains("HTTP_VIA") Then UpdateListbox(ListBox2, proxies(i)) Else UpdateListbox(ListBox1, proxies(i)) End If Catch ex As Exception 'MessageBox.Show(ex.ToString) used in testing UpdateListbox(ListBox4, proxies(i)) End Try completedProxyCheck += 1 lblTotalProxiesChecked.CustomInvoke(Sub(l) l.Text = completedProxyCheck) Next I have searched all over this site and via google, and most responses to this type of question say the response must be closed. I have tried a using block, eg: Using response As HttpWebResponse = request.GetResponse() Using sr As StreamReader = New StreamReader(response.GetResponseStream()) Dim pageSourceCode As String = sr.ReadToEnd() 'check the downloaded source for certain phrases, each identifies a type of proxy 'HTTP_X_FORWARDED_FOR identifies a transparent proxy If pageSourceCode.Contains("HTTP_X_FORWARDED_FOR") Then 'delegate method for cross thread safe UpdateListbox(ListBox3, proxies(i)) ElseIf pageSourceCode.Contains("HTTP_VIA") Then UpdateListbox(ListBox2, proxies(i)) Else UpdateListbox(ListBox1, proxies(i)) End If End Using End Using And it makes no difference (though i may have implemented it wrong) As you can tell im very new to VB or any OOP so its probably a simple problem but i cant work it out. Any suggestions or just tips on how to diagnose these types of problems would be really appreciated.

    Read the article

  • Looping through a file in VB.NET

    - by Ousman
    I am writing a VB.NET program and I'm trying to accomplish the following: Read and loop through a text file line by line Show the event of the loop on a textbox or label until a button is pressed The loop will then stop on any number that happened to be at the loop event and When a button is pressed again the loop will continue. Code Imports System.IO Public Class Form1 'Dim nFileNum As Integer = FreeFile() ' Get a free file number Dim strFileName As String = "C:\scb.txt" Dim objFilename As FileStream = New FileStream(strFileName, _ FileMode.Open, FileAccess.Read, FileShare.Read) Dim objFileRead As StreamReader = New StreamReader(objFilename) 'Dim lLineCount As Long 'Dim sNextLine As String Private Sub btStart_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles btStart.Click Try If objFileRead.ReadLine = Nothing Then MsgBox("No Accounts Available to show!", _ MsgBoxStyle.Information, _ MsgBoxStyle.DefaultButton2 = MsgBoxStyle.OkOnly) Return Else Do While (objFileRead.Peek() > -1) Loop lblAccounts.Text = objFileRead.ReadLine() 'objFileRead.Close() 'objFilename.Close() End If Catch ex As Exception MessageBox.Show(ex.Message) Finally 'objFileRead.Close() 'objFilename.Close() End Try End Sub Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles MyBase.Load End Sub End Class Problem I'm able to read the text file but my label will only loop if I hit the start button. It goes to the next line, but I want it to continue to loop through the entire file until I hit a button telling it to stop.

    Read the article

  • VB.NET: Dialog exits when enter pressed?

    - by Camilo Martin
    Hi all; My problem seems to be quite simple, but it's not working the intuitive way. I'm designing a Windows Forms Application, and there is a dialog that should NOT exit when the enter key is pressed, instead it has to validate data first, in case enter was pressed after changing the text of a ComboBox. I've tried by telling it what to do on KeyPress event of the ComboBox if e is the Enter key: Private Sub ComboBoxSizeChoose_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBoxSizeChoose.KeyPress If e.KeyChar = Convert.ToChar(Keys.Enter) Then Try TamanhoDaNovaFonte = Single.Parse(ComboBoxSizeChoose.Text) Catch ex As Exception Dim Dialogo2 As New Dialog2 Dialog2.ShowDialog() ComboBoxSizeChoose.Text = TamanhoDaNovaFonte End Try End If End Sub But no success so far. When the Enter key is pressed, even with the ComboBox on focus, the whole dialog is closed, returning to the previous form. The validation is NOT done at all, and it has to be done before exiting. In fact, I don't even want to exit on the form's enter KeyPress, the only purpose of the enter key on the whole dialog is to validate the ComboBox (but only when in focus, for the sake of an intuitive UI). I've also tried appending the validation to the KeyPress event of the whole dialog's form, if the key is Enter. NO SUCCESS! It's like my code wasn't there at all. What should I do? (Visual Studio 2008, VB.NET)

    Read the article

  • "Subforms" associated with tree view in VB

    - by knomdeguerre
    I am using VB Express 2008 to demonstrate my ideas for an improved UI for an existing product for my colleagues at work. The current UI has a certain page with ten tabs, allowing the user to define up to ten "things". The available choices for each of the ten "things" are all the same. On each of the ten tabs, there is a checkbox to enable that definition. Generally, a user will never use more than 5 or 6 unique definitions, the rest will remain disabled. So far, my prototype has a tree view control with one branch to contain this list of definitions, Add and Delete buttons. My idea is: there is one sub-branch to start with (corresponding to the first tab in the current UI); if the user wants addtional definitions, they click Add and other branches are added to the tree view, up to maximum of ten. I think I should be able to create a "class" that has a sub-UI (like a sub-form in Access) along with behavior code, that can be instantiated with each press of the Add button; each instantiation's settings can be set independently and is displayed in the main UI form )in a panel or frame) when selected in the tree view. For example, suppose the user Adds to make a total of three definitions: the tree view now has three sub-branches, each of which presents the same sub-UI with settings that can be set specific to the selected sub-branch. I'm sure it's possible but not sure how to do it. I know a comprehensive "answer" might be complicated and long, but I may just need some quick hints to get underway - don't be shy! Thanks in advance!

    Read the article

  • VB.NET 2008, Windows 7 and saving files

    - by James Brauman
    Hello, We have to learn VB.NET for the semester, my experience lies mainly with C# - not that this should make a difference to this particular problem. I've used just about the most simple way to save a file using the .NET framework, but Windows 7 won't let me save the file anywhere (or anywhere that I have found yet). Here is the code I am using to save a text file. Dim dialog As FolderBrowserDialog = New FolderBrowserDialog() Dim saveLocation As String = dialog.SelectedPath ... Build up output string ... Try ' Try to write the file. My.Computer.FileSystem.WriteAllText(saveLocation, output, False) Catch PermissionEx As UnauthorizedAccessException ' We do not have permissions to save in this folder. MessageBox.Show("Do not have permissions to save file to the folder specified. Please try saving somewhere different.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Catch Ex As Exception ' Catch any exceptions that occured when trying to write the file. MessageBox.Show("Writing the file was not successful.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try The problem is that this using this code throws an UnauthorizedAccessException no matter where I try to save the file. I've tried running the .exe file as administrator, and the IDE as administrator. Is this just Windows 7 being overprotective? And if so, what can I do to solve this problem? The requirements state that I be able to save a file! Thanks.

    Read the article

  • create and write to a text file in vb.net

    - by woolardz
    I'm creating a small vb.net application, and I'm trying trying to write a list of results from a listview to a text file. I've looked online and found the code to open the save file dialog and write the text file. When I click save on the save file dialog, I receive an IOException with the message "The process cannot access the file 'C:\thethe.txt' because it is being used by another process." The text file is created in the correct location, but is empty. The application quits at this line "Dim fs As New FileStream(saveFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Write)" Thanks in advance for any help. Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click Dim myStream As Stream Dim saveFileDialog1 As New SaveFileDialog() saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" saveFileDialog1.FilterIndex = 2 saveFileDialog1.RestoreDirectory = True If saveFileDialog1.ShowDialog() = DialogResult.OK Then myStream = saveFileDialog1.OpenFile() If (myStream IsNot Nothing) Then Dim fs As New FileStream(saveFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Write) Dim m_streamWriter As New StreamWriter(fs) m_streamWriter.Flush() 'Write to the file using StreamWriter class m_streamWriter.BaseStream.Seek(0, SeekOrigin.Begin) 'write each row of the ListView out to a tab-delimited line in a file For i As Integer = 0 To Me.ListView1.Items.Count - 1 m_streamWriter.WriteLine(((ListView1.Items(i).Text & vbTab) + ListView1.Items(i).SubItems(0).ToString() & vbTab) + ListView1.Items(i).SubItems(1).ToString()) Next myStream.Close() End If End If End Sub

    Read the article

  • asp.net vb user control raising an event on the calling page

    - by jvcoach23
    i'm trying to learn about user controls. I created a user control that has a textbox and a button. What i'd like to be able to do is when i click the button in the user control, populate a label in the aspx page. I understand that i could just have a button on the page that uses some properties on the user control to get that information.. but i'd like to know how to do it with the button the user control.. the reason for this is the button is just an example.. a learning tool. if i can get this working, i'd likely be putting thing in the user control that might require this kind of passing information. Anyway.. i've found some c# examples that i tried to get working as vb.. but once started getting into the delegates and events.. well.. it made me turn to this post. anyway.. hopefully someone can lend a hand.

    Read the article

  • Datareceived Serialport event stops raising after some seconds

    - by Mario
    Hi, I was hoping someone could help me out with this problem. I have a system (VB .NET) where I must read a person's weight (RS232 Sluice) and id (Fingerprint - 2 biometric reader, rs232) and compare it to a database. I have 3 serialports in my app, one for the sluice and the other 2 are to receive the id from the fingerprint readers, both of which call the same sub to get the id from the reader. I've been testing just one reader and it seemed to work fine, I got data from the datareceived and joined it together to get the id. The problem comes at this moment: I put a finger, sends the id, if it's ok sends a message, otherwise, writes the id to a textbox. But in-between reads, if I let 5 or 10 seconds pass without putting a finger on the reader it seems like I get no data at all anymore, the datareceived event nevers gets raised but if I keep putting a finger constantly it works pretty good, this is really weird to me. I was thinking of some things: **Maybe the port gets closed somehow after some time? I never call the CLose() method **The fact both datareceived eventhandlers call the same method and delegate **Maybe the connection settings are missing something? I tested with hyperterminal and the port keeps getting info even after time without activity and I use the same config with my application, maybe I need to change more settings like DTEenable and RTSenable? Please I need some help with this issue, it's to control access so it needs to be running 24/7 thanks in advance!

    Read the article

  • VB.net XML Parser loop

    - by StealthRT
    Hey all i am new to XML parsing on VB.net. This is the code i am using to parse an XML file i have: Dim output As StringBuilder = New StringBuilder() Dim xmlString As String = _ "<ip_list>" & _ "<ip>" & _ "<ip>192.168.1.1</ip>" & _ "<ping>9 ms</ping>" & _ "<hostname>N/A</hostname>" & _ "</ip>" & _ "<ip>" & _ "<ip>192.168.1.6</ip>" & _ "<ping>0 ms</ping>" & _ "<hostname>N/A</hostname>" & _ "</ip>" & _ "</ip_list>" Using reader As XmlReader = XmlReader.Create(New StringReader(xmlString)) Do Until reader.EOF reader.ReadStartElement("ip_list") reader.ReadStartElement("ip") reader.ReadStartElement("ip") reader.MoveToFirstAttribute() Dim theIP As String = reader.Value.ToString reader.ReadToFollowing("ping") Dim thePing As String = reader.ReadElementContentAsString().ToString reader.ReadToFollowing("hostname") Dim theHN As String = reader.ReadElementContentAsString().ToString MsgBox(theIP & " " & thePing & " " & theHN) Loop End Using I put the "do until reader.EOF" myself but it does not seem to work. It keeps giving an error after the first go around. I must be missing something? David

    Read the article

  • How do I get events to execute on the "main thread"

    - by William DiStefano
    I have 2 classes, one is frmMain a windows form and the other is a class in vb.NET 2003. frmMain contains a start button which executes the monitor function in the other class. My question is, I am manually adding the event handlers -- when the events are executed how do I get them to excute on the "main thread". Because when the tooltip balloon pops up at the tray icon it displays a second tray icon instead of popping up at the existing tray icon. I can confirm that this is because the events are firing on new threads because if I try to display a balloon tooltip from frmMain it will display on the existing tray icon. Here is a part of the second class (not the entire thing): Friend Class monitorFolders Private _watchFolder As System.IO.FileSystemWatcher = New System.IO.FileSystemWatcher Private _eType As evtType Private Enum evtType changed created deleted renamed End Enum Friend Sub monitor(ByVal path As String) _watchFolder.Path = path 'Add a list of Filter to specify _watchFolder.NotifyFilter = IO.NotifyFilters.DirectoryName _watchFolder.NotifyFilter = _watchFolder.NotifyFilter Or IO.NotifyFilters.FileName _watchFolder.NotifyFilter = _watchFolder.NotifyFilter Or IO.NotifyFilters.Attributes 'Add event handlers for each type of event that can occur AddHandler _watchFolder.Changed, AddressOf change AddHandler _watchFolder.Created, AddressOf change AddHandler _watchFolder.Deleted, AddressOf change AddHandler _watchFolder.Renamed, AddressOf Rename 'Start watching for events _watchFolder.EnableRaisingEvents = True End Sub Private Sub change(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs) If e.ChangeType = IO.WatcherChangeTypes.Changed Then _eType = evtType.changed notification() End If If e.ChangeType = IO.WatcherChangeTypes.Created Then _eType = evtType.created notification() End If If e.ChangeType = IO.WatcherChangeTypes.Deleted Then _eType = evtType.deleted notification() End If End Sub Private Sub notification() _mainForm.NotifyIcon1.ShowBalloonTip(500, "Folder Monitor", "A file has been " + [Enum].GetName(GetType(evtType), _eType), ToolTipIcon.Info) End Sub End Class

    Read the article

  • ASP.NET MVC (VB) error when publishing to test server

    - by Colin
    I have an ASP.NET MVC project that works fine on my local machine (no build errors, server errors or anything). However, when I publish the project to a test server, I get an "Object reference not set to an instance of an object" error on a For Each I have in my view. I have a function within a model that returns a DataRowCollection. I'm calling that function in my controller and passing the DataRowCollection to my View, which then iterates over the rows and displays the necessary information: In the Controller I have: Function Index() As ActionResult Dim MyModel As New Model ViewData("MyDataRowCollection") = MyModel.GetDataRowCollection() Return View() End Function And then in the View, which is throwing the error: <%@ Page Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> <asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server"> My Page Title </asp:Content> <asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server"> <% For Each MyDataRow In ViewData("MyDataRowCollection") ' do stuff with each MyDataRow Next %> I'm pretty new to ASP.NET MVC so I'm sure there might be a better way to do what I'm doing (I'd be happy to hear if there is), but my main concern is why this works fine on my local machine but throws an error on the For Each on the test server? Please let me know if I can clarify any of the above, and thanks in advance for any information.

    Read the article

  • VB.net avoiding cross thread exception with extension method

    - by user574632
    Hello I am trying to implement a solution for updating form controls without using a delegate. I am attempting to use the 1st solution on this page: http://www.dreamincode.net/forums/blog/143/entry-2337-handling-the-dreaded-cross-thread-exception/ Imports System.ComponentModel Imports System.Runtime.CompilerServices Public Module MyInvoke <Extension()> _ Public Sub CustomInvoke(Of T As ISynchronizeInvoke)(ByVal control As T, ByVal toPerform As Action(Of T)) If control.InvokeRequired Then control.Invoke(toPerform, New Object() {control}) toPerform(control) End If End Sub End Module The site gives this as example of how to use: Label1.CustomInvoke(l => l.Text = "Hello World!") But i get 'l' is not declared error. As you can see im very new to VB or any OOP. I can get the second solution on that page to work (using delegates) but i have quite a few things to do in this thread and it seems like i would need to write a new delegate sub for each thing, which seems wasteful. What i need to do is select the 1st item from a combobox, update a textbox.text with the selected item, and pass the selected item to a function. Then wait for x seconds and start again, selecting the second item. I can get it to work in a single threaded application, but i need the interface to remain responsive. Any help greatly appreciated. EDIT: OK so changing the syntax worked for the example. However if i change it from Label1.CustomInvoke(Sub(l) l.text = "hello world!") (which worked just fine) to: Dim indexnumber As Integer = 0 ComboBox1.CustomInvoke(Sub(l) l.SelectedIndex = indexnumber) I get a cross threading error as though i didnt even use this method: Cross-thread operation not valid: Control 'ComboBox1' accessed from a thread other than the thread it was created on. So now im back to where i started? Any further help very much appreciated.

    Read the article

  • query sql database for specific value in vb.net

    - by user2952298
    I am trying to convert VBA code to vb.net, im having trouble trying to search the database for a specific value around an if statement. any suggestions would be greatly appriciated. thedatabase is called confirmation, type is the column and email is the value im looking for. could datasets work? Function SendEmails() As Boolean Dim objOutlook As Outlook.Application Dim objOutlookMsg As Outlook.MailItem Dim objOutlookRecip As Outlook.Recipient Dim objOutlookAttach As Outlook.Attachment Dim intResponse As Integer Dim confirmation As New ADODB.Recordset Dim details As New ADODB.Recordset On Error GoTo Err_Execute Dim MyConnObj As New ADODB.Connection Dim cn As New ADODB.Connection() MyConnObj.Open( _ "Provider = sqloledb;" & _ "Server=myserver;" & _ "Database=Email_Text;" & _ "User Id=bla;" & _ "Password=bla;") confirmation.Open("Confirmation_list", MyConnObj) details.Open("MessagesToSend", MyConnObj) If details.EOF = False Then confirmation.MoveFirst() Do While Not confirmation.EOF If confirmation![Type] = "Email" Then ' Create the Outlook session. objOutlook = CreateObject("Outlook.Application") ' Create the message. End IF

    Read the article

  • Trying to Insert Text to Access Database with ExecuteNonQueryin VB

    - by user3673701
    I'm working on this feature were i save text from a textbox on my form to a access database file. With the click on my "store" button I want to save the text in the corresponding textbox fields to the fields in my access database for searching and retrieving purposes. Im doing this in VB The problem I run into is the INSERT TO error with my "store" button Any help or insight as to why im getting error would be greatly appreciated. here is my code: Dim con As System.Data.OleDb.OleDbConnection Dim cmd As System.Data.OleDb.OleDbCommand Dim dr As System.Data.OleDb.OleDbDataReader Dim sqlStr As String Private Sub btnStore_Click(sender As Object, e As EventArgs) Handles btnStore.Click con = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Eric\Documents\SPC1.2.accdb") con.Open() MsgBox("Initialized") sqlStr = "INSERT INTO Master FADV Calll info (First Name, Last Name, Phone Number, Email, User Id) values (" & txtFirstName.Text & " ' ,'" & txtLastName.Text & "','" & txtPhone.Text & "', '" & txtEmail.Text & "', '" & txtUserID.Text & "', '" & txtOtherOptionTxt.Text & "','" & txtCallDetail.Text & "');" cmd = New OleDb.OleDbCommand(sqlStr, con) cmd.ExecuteNonQuery() <------- **IM RECIVING THE ERROR HERE** MsgBox("Stored") ''pass ther parameter as sq; query, con " connection Obj)" con.Close()'

    Read the article

  • VB.NET Program Locks Up with Internet Explorer Opened

    - by aaronsj
    I'm using Visual Studio 2008 and developing a VB.NET application. I'm having strange lockup problems with my program, but only when Internet explorer 8 is opened. When I cover my form with another window and then uncover it, I find that it has locked up. My program has no references to IE and the only thing it even has to do with IE is using Process.Start with a web address. My program works fine and exactly as it should, but only when IE is not opened. Does anyone know why a program would lock up only while IE is running? Edit: I've done some digging and I've found the offending thread in my program. I don't know what starts this thread or what it does, but when I kill it, my program no longer freezes. The thread is one of the CreateApplicationContext threads, here is the last few items in the stack trace of that thread. 6 ntkrnlpa.exe+0x897bc 7 ntdll.dll!KiFastSystemCallRet 8 mscorwrks.dll!LogHelp_TerminateOnAssert+0x61 9 mscorwrks.dll!DllUnregisterServerInternal+0x10523 10 mscorwrks.dll!DllUnregisterServerInternal+0x10542 11 mscorwrks.dll!StrongNameErrorInfo+0x34387 12 mscorwrks.dll!StrongNameErrorInfo+0x34815 13 mscorwrks.dll!CreateApplicationContext+0xbc35 14 KERNEL32.dll!GetModuleHandleA+0xdf Process explorer says my program is using no CPU nor throwing any exceptions while it is hung.

    Read the article

  • NHibernate Entity code conversion from #C to VB.Net

    - by CoderRoller
    Hello and thanks for your help in advance. I am starting on the NHibernate world and i am experimenting with the NHibernate CookBook recipes, i am trying to set a base entity class for my entities and this is the C# code for this. I would like to know whats the VB.NET version so i can implement it in my sample project. This is the C# code: public abstract class Entity<TId> { public virtual TId Id { get; protected set; } public override bool Equals(object obj) { return Equals(obj as Entity<TId>); } private static bool IsTransient(Entity<TId> obj) { return obj != null && Equals(obj.Id, default(TId)); } private Type GetUnproxiedType() { return GetType(); } public virtual bool Equals(Entity<TId> other) { if (other == null) return false; if (ReferenceEquals(this, other)) return true; if (!IsTransient(this) && !IsTransient(other) && Equals(Id, other.Id)) { var otherType = other.GetUnproxiedType(); var thisType = GetUnproxiedType(); return thisType.IsAssignableFrom(otherType) || otherType.IsAssignableFrom(thisType); } return false; } public override int GetHashCode() { if (Equals(Id, default(TId))) return base.GetHashCode(); return Id.GetHashCode(); } } I tried using an online converter but puts a Nothing reference in place of default(TId) that doesn't seem right to me that's why I request for help: Private Shared Function IsTransient(obj As Entity(Of TId)) As Boolean Return obj IsNot Nothing AndAlso Equals(obj.Id, Nothing) End Function I Would appreciate the insight you may give me on the subject.

    Read the article

  • vb Syntax error in INSERT INTO statement

    - by user201806
    im new in vb, i was create a program to connection ms access but when i run the program it get syntax error in Insert into statement, OleDbExpection was unhandled here my code Public Class Form2 Dim cnn As New OleDb.OleDbConnection Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load txtdate.Value = DateTime.Now cnn = New OleDb.OleDbConnection cnn.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0; Data Source=C:\Users\John\Documents\db.mdb" End Sub Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click If Not cnn.State = ConnectionState.Open Then cnn.Open() End If Dim cmd As New OleDb.OleDbCommand cmd.Connection = cnn cmd.CommandText = "INSERT INTO sr(names,add,tel,dates,prob,serv,model,snm,acc,sna,remark)" & _ "VALUES ('" & Me.txtname.Text & "','" & Me.txtadd.Text & "','" & Me.txttel.Text & "', '" & _ Me.txtdate.Text & "','" & Me.txtpro.Text & "','" & Me.txtser.Text & "','" & Me.txtmod.Text & "', '" & _ Me.txtsnm.Text & "','" & Me.txtacc.Text & "','" & Me.txtsna.Text & "','" & Me.txtrem.Text & "')" cmd.ExecuteNonQuery() cnn.Close() End Sub End Class it's there any wrong with my code?

    Read the article

  • vb.net project template how can I leave the root namesapce empty

    - by Wietze Veld
    I have been tinkering with the VS 2010 template. So far I am able to create a vb.net class library project from my template. However, one small thing is bugging me. In my project template the default assembly name is the same as the default file name. I have left the root namespace empty. But when I create a new project from the template, VS 2010 automatically fills the root namespace with the same name as my assembly name. My template project (vbproj) for the assembly name and root namespace looks like this: <AssemblyName>$safeprojectname$</AssemblyName> <!-- RootNameSpace should always be empty. --> <RootNamespace></RootNamespace> But as said, when I leave this empty it is always overwritten with the assembly name. Even if I create a custom parameter with an empty string as value to replace the root namespace, it is still overridden. Any help is appreciated.

    Read the article

  • VB.Net Memory Issue

    - by Skulmuk
    We have an application that has some interesting memory usage issues. When it first opens, the program uses aroun 50-60MB of memory. This stays consistent on 32-bit machines. On 64-bit machines, however, re-activating the form in any way (clicking, dragging, alt-tabbing, etc.) adds around another 50MB to it's memory usage. It repeats this process several times before resetting back to around 45MB, at which point the cycle begins again. I've done some research and a lot of people have said that VB in general has pretty poor garbage collection, which could be affecting the software in some way. However, I've yet to find a solution. There are no events fired when the application is activated (as shown by 32-bit usage) - the applications is merely sitting awaiting the user's actions. At load, the system pulls some data into a tree view, but that's the only external connection, and it only re-fires the routine when the user makes a change to something and saves the change. Has anyone else experienced anything this strange, and if so, does anyone know of what might fix it? It seems strange that it only occurs under x64 systems. Thanks

    Read the article

  • Kill process started with System.Diagnostic.Process.Start("FileName")

    - by PedroC88
    Hello; I am trying to create an app that will perform actions on specific times (much like the Windows Task Scheduler). I am currently using Process.Start() to lunch the file (or exe) required by the task. I am initiating a process by calling a file (an .mp3) and the process starts WMP (since it is the default application), so far so good. Now I wan't to kill that process. I know that it is normal behavior for the Process.Start(string, string) to return nothing (null in C#) in this case. So I am asking how can i close WMP when I called it through Process.Start(string, string)?? Edit: Please note that I am not opening WMP directly with Process.Start() and this is the line with which I run the process: VB: Me._procs.Add(Process.Start(Me._procInfo)) C#: this._procs.Add(Process.Start(this._procInfo)) _procInfo is a ProcessStartInfo instance. _procInfo.FileName is "C:\route\myFile.mp3". That is why WMP opens. In any case, all of the Start() methods, except for the instance-one which returns a boolean, return nothing (null in C#), because WMP is not the process that was directly created (please note that WMP is run and the song does play).

    Read the article

  • VB Change Calulator

    - by BlueBeast
    I am creating a VB 2008 change calculator as an assignment. The program is to use the amount paid - the amount due to calculate the total.(this is working fine). After that, it is to break that amount down into dollars, quarters, dimes, nickels, and pennies. The problem I am having is that sometimes the quantity of pennies, nickels or dimes will be a negative number. For example $2.99 = 3 Dollars and -1 Pennies. SOLVED Thanks to the responses, here is what I was able to make work with my limited knowledge. Option Explicit On Option Strict Off Option Infer Off Public Class frmMain Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click 'Clear boxes lblDollarsAmount.Text = String.Empty lblQuartersAmount.Text = String.Empty lblDimesAmount.Text = String.Empty lblNickelsAmount.Text = String.Empty lblPenniesAmount.Text = String.Empty txtOwed.Text = String.Empty txtPaid.Text = String.Empty lblAmountDue.Text = String.Empty txtOwed.Focus() End Sub Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click 'Close application' Me.Close() End Sub Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click ' Find Difference between Total Price and Total Received lblAmountDue.Text = Val(txtPaid.Text) - Val(txtOwed.Text) Dim intChangeAmount As Integer = lblAmountDue.Text * 100 'Declare Integers Dim intDollarsBack As Integer Dim intQuartersBack As Integer Dim intDimesBack As Integer Dim intNickelsBack As Integer Dim intPenniesBack As Integer ' Change Values Const intDollarValue As Integer = 100 Const intQuarterValue As Integer = 25 Const intDimeValue As Integer = 10 Const intNickelValue As Integer = 5 Const intPennyValue As Integer = 1 'Dollars intDollarsBack = CInt(Val(intChangeAmount \ intDollarValue)) intChangeAmount = intChangeAmount - Val(Val(intDollarsBack) * intDollarValue) lblDollarsAmount.Text = intDollarsBack.ToString 'Quarters intQuartersBack = CInt(Val(intChangeAmount \ intQuarterValue)) intChangeAmount = intChangeAmount - Val(Val(intQuartersBack) * intQuarterValue) lblQuartersAmount.Text = intQuartersBack.ToString 'Dimes intDimesBack = CInt(Val(intChangeAmount \ intDimeValue)) intChangeAmount = intChangeAmount - Val(Val(intDimesBack) * intDimeValue) lblDimesAmount.Text = intDimesBack.ToString 'Nickels intNickelsBack = CInt(Val(intChangeAmount \ intNickelValue)) intChangeAmount = intChangeAmount - Val(Val(intNickelsBack) * intNickelValue) lblNickelsAmount.Text = intNickelsBack.ToString 'Pennies intPenniesBack = CInt(Val(intChangeAmount \ intPennyValue)) intChangeAmount = intChangeAmount - Val(Val(intPenniesBack) * intPennyValue) lblPenniesAmount.Text = intPenniesBack.ToString End Sub End Class

    Read the article

  • How can I read individual lines of a CSV file into a string array, to then be selectively displayed

    - by Ryan
    I need your help, guys! :| I've got myself a CSV file with the following contents: 1,The Compact,1.8GHz,1024MB,160GB,440 2,The Medium,2.4GHz,1024MB,180GB,500 3,The Workhorse,2.4GHz,2048MB,220GB,650 It's a list of computer systems, basically, that the user can purchase. I need to read this file, line-by-line, into an array. Let's call this array csvline(). The first line of the text file would stored in csvline(0). Line two would be stored in csvline(1). And so on. (I've started with zero because that's where VB starts its arrays). A drop-down list would then enable the user to select 1, 2 or 3 (or however many lines/systems are stored in the file). Upon selecting a number - say, 1 - csvline(0) would be displayed inside a textbox (textbox1, let's say). If 2 was selected, csvline(1) would be displayed, and so on. It's not the formatting I need help with, though; that's the easy part. I just need someone to help teach me how to read a CSV file line-by-line, putting each line into a string array - csvlines(count) - then increment count by one so that the next line is read into another slot. So far, I've been able to paste the numbers of each system into an combobox: Using csvfileparser As New Microsoft.VisualBasic.FileIO.TextFieldParser _ ("F:\folder\programname\programname\bin\Debug\systems.csv") Dim csvalue As String() csvfileparser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited csvfileparser.Delimiters = New String() {","} While Not csvfileparser.EndOfData csvalue = csvfileparser.ReadFields() combobox1.Items.Add(String.Format("{1}{0}", _ Environment.NewLine, _ csvalue(0))) End While End Using But this only selects individual values. I need to figure out how selecting one of these numbers in the combobox can trigger textbox1 to be appended with just that line (I can handle the formatting, using the string.format stuff). If I try to do this using csvalue = csvtranslator.ReadLine , I get the following error message: "Error 1 Value of type 'String' cannot be converted to '1-dimensional array of String'." If I then put it as an array, ie: csvalue() = csvtranslator.ReadLine , I then get a different error message: "Error 1 Number of indices is less than the number of dimensions of the indexed array." What's the knack, guys? I've spent hours trying to figure this out. Please go easy on me - and keep any responses ultra-simple for my newbie brain - I'm very new to all this programming malarkey and just starting out! :)

    Read the article

  • Parsing XML with VB.net.

    - by SuperFurryToad
    I'm trying to make sense of a big data dump of XML that I need to write to a database using some VB.net code. I'm looking for some help getting started with the parsing code, specifically how to access the attribute values. <Product ID="523233" UserTypeID="Property" ParentID="523232"> <Name>My Property Name</Name> <AssetCrossReference AssetID="173501" Type=" Non Print old"> </AssetCrossReference> <AssetCrossReference AssetID="554740" Type=" Non Print old"> </AssetCrossReference> <AssetCrossReference AssetID="566495" Type=" Non Print old"> </AssetCrossReference> <AssetCrossReference AssetID="553014" Type="Non Print"> </AssetCrossReference> <AssetCrossReference AssetID="553015" Type="Non Print"> </AssetCrossReference> <AssetCrossReference AssetID="553016" Type="Non Print"> </AssetCrossReference> <AssetCrossReference AssetID="553017" Type="Non Print"> </AssetCrossReference> <AssetCrossReference AssetID="553018" Type="Non Print"> </AssetCrossReference> <Values> <Value AttributeID="5115">Section of main pool</Value> <Value AttributeID="5137">114 apartments, four floors, no lifts</Value> <Value AttributeID="5170">Property location</Value> <Value AttributeID="5164">2 key</Value> <Value AttributeID="5134">A comfortable property, the apartment is set on a pine-covered hillside - a scenic and peaceful location.</Value> <Value AttributeID="5200">YYY</Value> <Value AttributeID="5148">facilities include X,Y,Z</Value> <Value AttributeID="5067">Self Catering. </Value> <Value AttributeID="5221">Frequent organised daytime activities</Value> </Values> </Product> </Product> Thanks in advance for your help.

    Read the article

  • vb.net one dimensional string array manipulation difficulty

    - by Luay
    Hi, I am having some problems with manipulating a one dimensional string array in vb.net and would like your assistance please. My objective is to get 4 variables (if possible) from a file path. these variables are: myCountry, myCity, myStreet, Filename. All declared as string. The file location is also declared as string. so I have: Dim filePath As String to illustrate my problem and what I am trying to do I have the following examples: 1- C:\my\location\is\UK\Birmingham\Summer Road\this house.txt. In this example myCountry would be= UK. myCity= Birmingham. myStreet=Summer Road. Filename=this house.txt 2- C:\my Location\is\France\Lyon\that house.txt. here myCountry=France. myCity=Lyon. There is no street. Filename=that house.txt 3- C:\my Location is\Germany\the other house.txt Here myCountry=Germany. No city. No street. Filename=the other house.txt What I am trying to say is I have no idea before hand about the lenght of the string or the position of the variables I want. I also don't know if I am going to find/get a city or street name in the path. However I do now that i will get myCountry and it will be one of 5 options: UK, France, Germany, Spain, Italy. To tackle my problem, the first thing I did was Dim pathArr() As String = filePath.Split("\") to get the FileName I did: FileName = pathArr.Last To get myCountry I did: If filePath.Contains("UK") Then myCountry = "UK" ElseIf filePath.Contains("France") Then myCountry = "France" ElseIf filePath.Contains("Germany") Then myCountry = "Germany" ElseIf filePath.Contains("Spain") Then myCountry = "Spain" ElseIf filePath.Contains("Italy") Then myCountry = "Italy" End If in trying to figure out myCity and myStreet (and whether they exist in the string in the first place) I started with: Dim ind As Integer = Array.IndexOf(pathArr, myCountry) to get the index of the myCountry string. I thought I could make my way from there but I am stuck and don't know what to do next. Any help will be appreciated. Thanks

    Read the article

< Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >