|
I had a Question I was hoping you might be able to help me with.
I am using VB.NET 2005 express and I have a list box that is bound to a table in a dataset. I want to be able to select one of the items in the list box and then use an item that corresponds to this item in the list box and I do not know how to do this.
For example, if I had a table named Person and this table had two fields one named PersonID (which is the key field), PersonName, and PersonAge. Say I had PersonName bound to the list box. So say I click on one of the PersonNames in the list box and then wanted to use the PersonAge, which corresponded to the name I had clicked, in a calculation. How would I access the PersonAge value?
I appreciate any help you could give me.
Thanks
|
|
|
|
|
Bind your datatable like this:
ListBox1.DisplayMember = "PersonName"<br />
ListBox1.ValueMember = "PersonAge"<br />
ListBox1.DataSource = dtMyDataTable
And then refer to the ListBox1.SelectedValue to get the person's age.
Hope this helps.
|
|
|
|
|
|
Probably permissions, although you don't provide a lot of info. Can you read the file normally ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello,
I thought I had this resolved.
The problem is this. I have deployed a program in the folder where the setup file is, I have a folder called CodeRed_1_0_0_10, inside that folder I have a file called CodeRed.exe.config.deploy. I want to be able to access this file.
The path is this:
C:\Deployed_4_10_06\CodeRed_1_0_0_10.
The setup.exe file is located in the Deployed_4_10_06 folder. I thought by using application.startuppath would point to this directory. However, after checking I found out that is points to this one below:
C:\Documents and Settings\yasin\Local Settings\Apps\2.0\YDBGO2AL.YA3\TOMO6HER.GJR\code..tion_53e3de40adb22891_0001.0000_adfb41cfb825f353
I thought by using this:
path = Application.StartupPath & "\CodeRed_1_0_0_11\" & "CodeRed.exe.config.deploy"
I would be able to update my file, but cannot not.
Is there a way to be able to point to the file where the setup.exe is located?
Many thanks in advance,
Steve
|
|
|
|
|
i'm trying to develop an addin for vb.net that allows the user to add a new (code created) class to the solution by right clicking on the solution in solution explorer and selecting a new context menu item from the list. this code will be dynamically generated based on some user input so cant be created by using a wizard.
i've been able to generate the class dynamically and add it to the solution etc. the one thing i havent been able to figure out is how to create the menu item so that it only appears when a "solution" type node is selected in the solution explorer window.
any help in this area would be appreciated
thanks in advance
swampy
|
|
|
|
|
I try to read data into array and display the data, however i only manage to get 1 in return. Below is my coding, may i have some suggestion and advice?
Option Strict On
Imports System.IO
Public Class Form1
Private Function Language(ByVal MLanguage As Integer, ByVal RequestDataID() As Integer, ByRef GetBackWord() As String) As String
Dim s As String = String.Empty
Dim Number As Integer = 0
Dim sFileName As String
If MLanguage = 1 Then
sFileName = "C:\testing.txt"
Try
Dim oFile As FileStream = New FileStream(sFileName, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim oReader As StreamReader = New StreamReader(oFile)
Dim a As Integer = 0
Do Until (Number = RequestDataID(a))
If Number < RequestDataID(a) Then
s = oReader.ReadLine()
Language = s
'GetBackWord(6) = s
Number += 1
a += 1
Else
s = oReader.ReadLine()
End If
Loop
oReader.Close()
oFile.Close()
Catch
GetBackWord(0) = "a."
End Try
ElseIf MLanguage = 2 Then
sFileName = "C:\Maklumat.txt"
Try
Dim oFile As FileStream = New FileStream(sFileName, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim oReader As StreamReader = New StreamReader(oFile)
Dim a As Integer = 0
Do Until (Number = RequestDataID(a))
If Number < RequestDataID(a) Then
s = oReader.ReadLine()
GetBackWord(a) = s
Number += 1
a += 1
Else
s = oReader.ReadLine()
End If
Loop
oReader.Close()
oFile.Close()
Catch
GetBackWord(0) = "a"
End Try
Else
sFileName = "C:\CMsg.txt"
Try
Dim oFile As FileStream = New FileStream(sFileName, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim oReader As StreamReader = New StreamReader(oFile)
'Dim a As Integer = 0
Do Until (Number = RequestDataID(6))
If Number < RequestDataID(6) Then
s = oReader.ReadLine()
GetBackWord(6) = s
Number += 1
'a += 1
Else
s = oReader.ReadLine()
End If
Loop
oReader.Close()
oFile.Close()
Catch
GetBackWord(0) = "a"
End Try
End If
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As Integer = 0
Dim sss() As String = {""}
Dim aaa() As Integer = {1, 2, 3, 4, 5, 6, 7}
'ReDim Preserve aaa(6)
Do Until a = 5
MessageBox.Show(Language(1, aaa, sss))
a += 1
Loop
End Sub
End Class
|
|
|
|
|
TeiUKei wrote: s = oReader.ReadLine()
Language = s
This seems redundant. Either way, your return value is being changed every time, not accumulated. Is that the intention ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
No, my intention is for example, everytime i receive a requestID(3), i will read 4 lines from the textfile and store in the array, GetBackWord(3) and display the lines i get. Any suggestion? I stuck there and be so appreciate for help.
|
|
|
|
|
I'm not really sure what you mean. The code looks messy - perhaps if you told us what's in the file, and what you expect the function to return ( and what you're getting instead ) ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Well, this is the data in the file
No,Title
1,Error Message
Information
Question
a
b
c
d
e
f
Let say i receive RequestDataID = {1,2,3,4,5,6,7}, then for RequestDataID(0),line 1 will be read and stored in GetBackWord(0) which then send back to the function called and same with the other. However, i only manage to get c in return. What should i suppose to do?
|
|
|
|
|
I honestly can't work out how this code is supposed to work. Really, what you should do is read the entire file into an array, File.ReadAllLines (from memory ) does this. Then you can copy whatever lines you want.
Other suggestion - set a breakpoint and step through your code to try and work out where it's going wrong.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Well, thanx for help anyway!!
|
|
|
|
|
I was hoping we might dig a little deeper. Does File.ReadAllLines ( or whatever it is ) help ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I checked my code and wondered if it was because RichTextbox only take the recent memory, that's why it only displayed one of it.
|
|
|
|
|
The rich text box will show exactly what you ask it to. If the function returns what you expect, then the problem is how you assign it to the rich text box.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Well, i solve the problem of display data. Thanx!!!
|
|
|
|
|
Is there an event or means of establishing when the user cancels a drag and drop operation?
Lets say the user is dragging something over my control. How will i know if the user cancelled the operation (i.e. by pressing escape)? Do i have to write custom code for it or is there an easy way?
Also, on a slightly related matter, how can i find out if the mouse button is down?
I need a mouse equivilent to My.Computer.Keyboard.CtrlKeyDown
Such as My.Computer.Mouse.LeftButtonDown
|
|
|
|
|
I think there's a syskey event for system keys. I know that the normal key events have flags for CTRL and ALT, so they don't generate an event by themselves ( I don't think )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
i need a vb code for barcode Daily time record attendance. pls help. send it to my email add lustrac@yahoo.com or post it here.. thanks a lot..
chris
|
|
|
|
|
You seem to have this site confused with rentacoder.
There is code for reading barcodes on the site, the rest shouldn't be too hard. If it is, you can ask for help, but no-one will do your job for you.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
If you're writing any code, you can add parameters to the Paramaters collection. If you're not writing any code, I have no idea how all that wizard rubbish works.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I don't understand the question.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Probably a simple question but i have a class called LukeClass.
I have a Shared variable called LukeSharedVar in that class.
I do not create any instances of that class, but i call LukeClass.LukeSharedVar = "Luke"
Does a new instance get created? I dont understand what happens if you modify a shared property/variable of a class without having any instances of that class in memory...
|
|
|
|
|
No, setting the value of a static (shared in VB) member does not create an instance of the class.
The static members are stored in the memory area for the class. This memory area is allocated when the assembly is loaded. There is only set of the static members for a class, regardless if there are zero or a million instances of the class.
---
b { font-weight: normal; }
|
|
|
|