|
Yes, this works, what you need to research is how to load an image from resources. I have done it in C#, but not VB.NET.
protected Image GetImageFromResources(string name)
{
// get a reference to the current assembly
Assembly a = Assembly.GetExecutingAssembly();
string my_namespace = a.GetName().Name.ToString();
Image image = null;
image = new Bitmap(a.GetManifestResourceStream(my_namespace + "." + name));
return image;
}
is the method I use. IF you have a folder called Bitmaps, a folder called Girls, and a file called Jessica.jpg, you'd pass "Bitmaps\Girls\Jessica.jpg" to this method. The folders get turned into namespaces, actually.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I think you want to reference them this way:
My.Resources.[Image Name here] A property is actually created when you add a resource so under My.Resources there should be a property with your images name.
|
|
|
|
|
|
Hello!
I would like to create an application in VB6 (preferably, but VB.NET can be used) which will allow me to view/edit files store on a hidden partition in windows. To make matters worse, the hidden partition is on a compact flash and not a harddrive.
I have checked the CF using device manager. There are 3 or 4 paritions, the primary partition (which Explorer can access), and an extended partition with 2 or 3 logical partitions on it. I would like to see / add / remove files to these partitions.
I have no idea where to start (a DriveBox wont see the partitions, nor will the fso, and I have experimented a little with WMI but not too much).
Can somebodjy give me some pointers please? Or, can Windows actually view hidden partitions on a CF (I have Windows XP Pro - that is the only OS that I am interested in).
Thankyou
|
|
|
|
|
Partitions are not accessible using standard methods and controls. DriveBox won't see them. Partitions contain Volumes, the type of which is determined by the file system that created the volume. DriveBox WILL see volumes if they are valid and assigned a drive letter.
Since none of the standard file methods will work on hidden volumes and partitions, you'll have to write all of the low-level code to parse and interpret the volumes in these partitions. NOT a fun job...
Your better option is to use a Partition Management (like Partition Magic) utility to remove the hidden attribute from the partitions so you can then see the volumes (if any!) on them and use the standard File I/O methods to access them.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi All,
Im trying to get fields from a database to show in a combo box. I am able to do this through the wizard, but would prefer to do it manually. this is what I've done so far, but obviously it doesnt work, was just hoping someone could tell me where im going wrong.
ComboBox2.Text = dataSet.Tables("Requirement").Rows(inc).Item("RequirementType")
ComboBox2.Text = dataSet.Tables("Requirement").Rows(2).Item("RequirementType")
This obviously doesnt work! (only shows ONE field)
Also is there a way to manually make a list of things you want to put into the combo box?
Thanks in advance
Jaidev
|
|
|
|
|
ComboBox2.DataSource = dataset.Tables("Requirement")
ComboBox2.DisplayMember = "RequirementType"
ComboBox2.DataBind()
something like that
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
How i add new item to combo box during runtime ? for example , i want add new "Please select" as first item to display with it's value -1 ?
Best regards,
Chee ken
|
|
|
|
|
hi guys
i need to put multi forms in a main form
i want to make the application in one main form
and on clicking buttons i change forms included in the main one
for more info plz see this picture that explaine
http://img478.imageshack.us/img478/5970/multiformhp8.jpg[^]
i'm using vb.net 2003
|
|
|
|
|
Create your multiple 'forms' as controls, put them on your form, and show/hide them as needed.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
Use the WindowsControllibrary project or right click on your existing project select add then add new item then select usercontrol.
|
|
|
|
|
I am working on a Datagrid in ASP.Net using VB. The datagrid is linked to an SQL Server database and uses the EditCommandColumn for editing. The issue that I am running into is that the client for the web application wants to use one datagrid to edit two different types of invoices. This causes an issue because certain fields on one invoice can be edited while the other invoice only allows one field to be edited. I need to have a way to set and unset the Readonly property for my BoundColumns based on the type of invoice it is. Is there someway to set the correct Readonly property for each column when the user clicks on Edit? I would appreciate any ideas or suggestions on the best way to do this. Thank you in advance.
|
|
|
|
|
may be custom code!! like instead of using the predefined edit link you create something like edit1 and write your logic accordingly!!!
Gautham
|
|
|
|
|
I've got a bound DataGridView that performs some validation exactly as I want it to - providing I don't have the columns formatted.
A code snippet example of the validation that works when I don't format the columns is:
<br />
If CType(e.ProposedValue, Integer) <= intPreviousToValue Then<br />
e.Row.RowError = "Error message"<br />
e.Row.SetColumnError(e.Column, "Error message")<br />
End If<br />
Using the standard VB.NET 2005 Express formatting properties, the columns are formatted to be:
Column 0 - Numeric - no decimals
Column 1 - Numeric - no decimals
Column 2 - Currency - two decimals
If I take the formatting out, the grid validation works fine - if I put the formatting back in, I can't get the validation to work.
What am I breaking by putting the formatting in?
|
|
|
|
|
Anybody got any thoughts on this?
One thing I forgot to say is that if I put a msgbox in place, when the conditions are met, it show the message - its just the errorprovider notification icon that I can't get.
|
|
|
|
|
Hi all,
i have been trying to create some function that take the Decimal datatype to convert decimal to hexadecimal and the reverse.
my code at present uses the long datatype which go up to 9.2 E+18. Currently i am working with larger numbers.
This is my code:
Private Function ConvertDecimalToHexadecimal(ByVal number As Decimal)<br />
Dim converted As String<br />
Dim value As Long = Long.Parse(number)<br />
converted = value.ToString("X")<br />
Return converted<br />
End Function
Private Function ConvertHexadecimalToDecimal(ByVal number As String)<br />
<br />
Dim txt As String<br />
Dim value As Decimal<br />
Dim converted As String<br />
<br />
txt = UCase(Trim(number))<br />
If txt.StartsWith("&H") Then txt = txt.Substring(2)<br />
value = long.Parse(txt, Globalization.NumberStyles.HexNumber)<br />
converted = value.ToString()<br />
Return converted<br />
<br />
End Function
Is there some way of making this work for numbers up to the decimal datatype of 1.79 E+308
or if anyone knows of another way?
Thanks
|
|
|
|
|
Hi,
According to Microsoft's .NET documentation, you'll have to either use the Double type instead of Long or round you numbers to a more manageable size, before handling them.
On a less helpful note, you could make your function a little smaller like so:
<br />
Private Function ConvertDecimalToHexadecimal(ByVal number As Decimal) As String<br />
Return Double.Parse(number).ToString("X")<br />
End Function<br />
<br />
Private Function ConvertHexadecimalToDecimal(ByVal number As String) As String<br />
If UCase(Trim(number)).StartsWith("&H") Then number = number.Substring(2)<br />
Return Double.Parse(number, Globalization.NumberStyles.HexNumber).ToString<br />
End Function<br />
Hope it helps,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
I couldn't find any built in functions to do such large conversions. However, I had some code to convert Hex to Dec and vice versa. I made some modifications to ensure the conversion would work with the largest decimal number allowed. Here is the code which I believe works perfectly. If you discover a problem let me know. Hope this helps.
Public Class Form1
'Test conversion of the largest allowed decimal value
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim msg As String = "MaxDecimal: " & Decimal.MaxValue.ToString & _
vbCrLf & "MaxDecimal as Hex: " & DecToHex(Decimal.MaxValue).ToUpper & _
vbCrLf & "Hex converted back: " & HexToDec(DecToHex(Decimal.MaxValue)).ToString
MsgBox(msg)
End Sub
'---MAIN CONVERSION FUNCTIONS---
'Converts a decimal type to it's Hex value
'Does not support fractional numbers, so don't pass them :)
'Actually they just get rounded so nothing to worry about.
Private Function DecToHex(ByVal number As Decimal) As String
number = Decimal.Round(number)
Dim result As New System.Text.StringBuilder
Do While number > 0
Dim remainder As Integer = number Mod 16
number = number / 16D
number = Decimal.Truncate(number)
result.Insert(0, DecToHexChar(remainder))
Loop
Return result.ToString
End Function
'Converts a string of Hex characters to it's decimal equivalent
'Does not provide any validation. String must have nothing but
'valid Hex values. Although no errors should occur.
Private Function HexToDec(ByVal hex As String) As Decimal
Dim result As Decimal
For i As Decimal = 0 To hex.Length - 1
Dim chr As Char = hex.Chars(i)
result += (HexCharToDec(chr) * Pow(16, hex.Length - 1 - i))
Next
Return result
End Function
'---HELPER FUNCTIONS---
'Converts a Decimal value 0 to 15 to it's Hex character equivalent
'If number is anything else it returns String.Empty
Private Function DecToHexChar(ByVal number As Integer) As String
If number < 10 Then Return number
Select Case number
Case 10 : Return "A"
Case 11 : Return "B"
Case 12 : Return "C"
Case 13 : Return "D"
Case 14 : Return "E"
Case 15 : Return "F"
End Select
Return String.Empty
End Function
'Converts a Hex character to it's decimal equivalent
'Valid characters: 0-9, A-F
'Returns -1 if invalid
Private Function HexCharToDec(ByVal chr As Char) As Decimal
If Char.IsDigit(chr) Then Return Decimal.Parse(chr)
Select Case Char.ToUpper(chr)
Case "A" : Return 10D
Case "B" : Return 11D
Case "C" : Return 12D
Case "D" : Return 13D
Case "E" : Return 14D
Case "F" : Return 15D
End Select
Return -1D
End Function
'Raises a number to a given power
'Math.Pow and ^ were not options because they don't handle up to decimal
Private Function Pow(ByVal number As Decimal, ByVal exponent As Integer) As Decimal
Dim result As Decimal = 1
For i As Integer = 1 To exponent
result *= number
Next
Return result
End Function
End Class
-- modified at 22:38 Friday 9th February, 2007
|
|
|
|
|
Is there a VB.Net way to enumerate objects in a program running as a free standing exe?
RCarey
|
|
|
|
|
A program that's running, and is not your program ? No.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
My program. I want to click a debug menu item and get a list of objects that exist at that time. Ditto for threads.
RCarey
|
|
|
|
|
OK, you can do that with reflecton. You can reflect over your objects and get out variable names and values.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I run Win XP sp2 and want to monitor a server. I have searched the web left to right, but I cannot find out how I retrive information about the chassis temperature or what workgroup a server is in.
There are plenty of examples showing how to display the computer name for example Private Declare Function GetComputerName Lib "kernel32".
I though I could use WMI to find the temperature. Does anybody have a small code sample?
To find the workgroup I read something about netapi32. But it seems very complex. Surely there must be an easy way to check the name of the net workgroup a computer is in.
As you can understand, I am a VBA novice .
Help greatly appreciated.
|
|
|
|
|
How to dissallow the user to open an opened form
I mean dont allow to create many instance of the same form
(if form is open dont open it again
Regards
Ramy
|
|
|
|