Skip to content

Visual Basic

Visual Basic Questions

This category can be followed from the open social web via the handle visual-basic@forum.codeproject.com

34.4k Topics 120.1k Posts
  • ComboBox

    csharp question
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Read a record in SQL and .NET

    database tutorial csharp
    2
    0 Votes
    2 Posts
    0 Views
    J
    There should be lots of examples out there of how to return multiple records, looping through records, returning one record etc. But here's a simple example of how I get back a record from a SELECT statement: Private Function GetCustName(ByVal CustNum As String) As String Dim strConn As String = ConfigurationSettings.AppSettings.Item("connectionstring") 'Read connection string from web.config Dim conSQL As New SqlConnection(strConn) 'Create the connection Dim cmdSQL As New SqlCommand("SELECT CustName FROM Customers WHERE CustNum ='" & CustNum & "'", conSQL) 'The query I want to run Dim Rdr As SqlDataReader conSQL.Open() 'Open the connection Rdr = cmdSQL.ExecuteReader() 'Execute the query Rdr.Read() 'Read the record (only returns ONE record!) GetCustName = IIf(IsDBNull(Rdr("CustName")), "", Rdr("CustName")) 'Read the value from a field called 'CustName' conSQL.Close() End Function This function returns a value from a record when you pass it a search criteris. If you want to populate text boxes on your form, then after the 'Rdr.Read()' line, you could do something like: myName.text = Rdr("Name") myAddress1.text = Rdr("Address1") myAddress2.text = Rdr("Address2") etc... Hope this helps, Regards, John. www.silveronion.com[^]
  • 0 Votes
    1 Posts
    0 Views
    No one has replied
  • Zoom/Pan/Scrollable PictureBox

    csharp help question
    4
    0 Votes
    4 Posts
    0 Views
    J
    I'm going to finish my viewport myself and maybe I'll send a copy to you. Too bad the .NET scrolling support is so lousy, but what they didn't give us, we can make ourselves. "Do unto others as you would have them do unto you." - Jesus "An eye for an eye only makes the whole world blind." - Mahatma Gandhi
  • 0 Votes
    1 Posts
    0 Views
    No one has replied
  • First visible Row in DataGrid

    csharp database help tutorial
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Exposing a type safe collection for data binding

    wpf wcf com question
    3
    0 Votes
    3 Posts
    0 Views
    D
    It turns out I should have implemented IBindableList not IListSource. Now the datagrid lists my control as a source in the DataBindings but it doesn't show any columns - I take it it doesn't know what the type safe collection type looks like? How do I add property descriptions to my existing class so the data bound grid can pick them up? '--8<------------------------ Ex Datis: Duncan Jones Merrion Computing Ltd
  • Sort a collection

    algorithms question
    3
    0 Votes
    3 Posts
    0 Views
    S
    I'm using standard collection object but the sort method doesn't exist on collection object.
  • Dialing a number

    question csharp help
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Problem on moving objects at design time

    help csharp com design
    3
    0 Votes
    3 Posts
    0 Views
    T
    Thank you for your answer. I already know the Lock property (in the popup menu) But the problem is not connected with it. There is no problem on placing. After placing when I try to move one of "ALL" objects it causes. They are not locked. Also I cannot use "CTRL+C" keys to copy or "Delete" keys to remove a control when this happens. Best Regards Emre YAZICI
  • Length of a MenuItem in pixels

    csharp help question
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Hiding columns in ListView

    csharp winforms question
    2
    0 Votes
    2 Posts
    0 Views
    V
    Hello, There is no other way to do it. You implemented is right thing. I just have a additional to tell you. Assign ColumnResize value to none means one can not resize the column. Then while filling data in ListView calculate the length of the record which you are filling currently. Then assign the record lenght value to the column width. By doing this, you will able to see full length data in your ListView without facing problem. Example for consideration: Dim iLenght as Integer ' Lenght of the record Dim iPrevMaxLength as Integer ' Length of previous record iLength = 0 iPrevMaxLength = 0 While(rs.EOF != NULL) 'Todo part ..... ..... ..... ..... iLength = len(rs.CurrentRecord) if iLength > iPrevLength then ListView.Column(index).width = iLength iPrevMaxLength = iLength end if ' Todo part ..... ..... ..... ..... Wend Let me know if this works or not. Regards, Vilas Shewale ;)
  • Sort Array?

    help algorithms data-structures tutorial
    3
    0 Votes
    3 Posts
    0 Views
    U
    I always sort arrays using For loops. It might be a little slow for large arrays, but it always works for me: Dim myNewArray() As String, q As Integer, r As Integer, s As Integer, t As Integer ReDim myNewArray(UBound(myOldArray, 0), UBound(myOldArray, 1)) r = 9999999 'Just a big number (bigger than the biggest number in your array) s = 0 For q = 0 To UBound(myOldArray, 0) If myOldArray(q, 0) <= r Then For t = 0 To UBound(myOldArray, 1) myNewArray(s, t) = myOldArray(q, t) Next s = s + 1 r = myOldArray(q, 0) End If Next I haven't tested this code, since I don't have VB6 installed at the place I currently am, but it should work. Just replace myOldArray by your array. You could even put this in a function, returning a String(). "Make peace, not war"
  • Creating a date

    help question
    3
    0 Votes
    3 Posts
    0 Views
    S
    I know a year and a week For example 2003 week 13 And I want to get the full date of the thuseday of this week. So in my exemple, the function should return 04/27/2003
  • Adding icons to menus in VB.NET

    question csharp graphics help
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Problem to use ListSubItem Object in ListView

    help
    2
    0 Votes
    2 Posts
    0 Views
    D
    Don't use the add method. Try this: Dim si As ListSubItem Dim li As ListItem Dim i, J As Integer For i = 1 To 20 Set li = ListView1.ListItems.Add(Text:="Item " & i) For J = 1 To 4 Set si = li.ListSubItems(J).Text = "Subitem " & J si.ForeColor = vbRed Next J Next i
  • Reference spreadsheet needs to be open

    database sales tools question career
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • OLE from VB6 in C#

    question csharp com testing
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Calling an .exe inside VB.NET

    question csharp help
    2
    0 Votes
    2 Posts
    0 Views
    B
    never mind i found how it works http://www.devx.com/dotnet/Article/7914/0/page/5
  • Burning CDs programatically

    question
    2
    0 Votes
    2 Posts
    0 Views
    J
    If you have Nero 5.5 you could download their free sdk . http://www.ahead.de/en/content/c1002825712128.html#c1002825712128[^] I didn't used ... yet ... Cheers,Joao Vaz And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9 Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech