|
VC++? --> Throw New Exception("Wrong Board")
To Browse for a file have a look at the OpenFileDialog Class in the MSDN, it's ready to use.
To Open a File you can use old legacy Open VB statement (definetly not advisable) or open it through one of the .NET provided classes. It really depends on the file content and waht are you to do with it.
|
|
|
|
|
hi all,
I need some help in Vb.net or VB6 i would like to retrive the public IP of the system which is similar to the http://www.nirsoft.net/show_my_ip_address.php i would like to Retrive even if i a behind the firewall. Can any one help me on that. If you have one please mail me the code to
suresh@fuseflow.com
Thanks in Advance
Sur
|
|
|
|
|
You have two options to write this application.
1) You can write an application to try to resolve the host name assigned to you by your ISP. This will usually return the IP address assigned to you. (This one is easier!)
2) Or, you can write your application to talk to your router and get the address from either a telnet server on your router or from a web page from your router. In iether case, you'll have to parse the data returned to get at the address.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Does VB .NET 2003 have a bug with the UrlEncode method?
It will not convert ' to %27
As a result HREF using Request.QueryString.ToString fails due to an extra quote.
For example:
F1="Fred's Fish"
F1 = Server.UrlEncode(F1)
'F1 returns "Fred's+Fish"
I am having to write a replacement function for UrlEncode.
Gary
|
|
|
|
|
There are no known issues with the .UrlEncode() method.
But since you're putting this path into an A HREF tag, shouldn't you be using .UrlPathEncode() instead?
HttpServerUtility.UrlPathEncode Method[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for responding.
I don't need .UrlPathEncode since I am creating a custom link to another page.
As for the .UrlEncode shouldn't it encode a Quote character?
I have traced it and a ' does not encode to %27. What am I missing?
Gary
|
|
|
|
|
I would like to save the Font properties of the control in a text .ini file to retreive these properties by reading again the file.
There is a brute force way of doing like:
sw.WriteLine(ListView1.ForeColor)
sw.WriteLine(ListView1.BackColor)
sw.WriteLine(ListView1.Font)
It gives the following result(by example):
Color [WindowText]
Color [WhiteSmoke]
[Font: Name=Arial, Size=9,75, Units=3, GdiCharSet=0, GdiVerticalFont=False]
Then to retreive the properties we must parse each lines to extract the values.
This is wordy and not very elegant.
Is there somebody having a smarter way of doing?
Thank's in advance.
Patrice
-- modified at 13:52 Thursday 29th September, 2005
|
|
|
|
|
you can use the registry to save each property of the font in a variable.
when you want to retreive these properties from the registry... intiate a new font object with these retreived strings.
militiaware...Faris Madi
|
|
|
|
|
Thank you for your reply. Yes I have notice this possibility, but I do not want to use the registry. Due to portability issues I don't want this. The curious thing is that I have heard in a webcast a guy saying that there were NO MORE registry with .NET. I don't know if the framework does not need for itself the registry but, do Microsoft has provided a way to convert a string in a system.drawing.color object?
the instruction like :
ListView1.BackColor = "black"
give the error: Value of type string canot be converted to 'system.drawing.color'
That mean that the only way I see is:
sColor="black"
Select case sColor
case "red"
case "green"
...
case "black"
ListView1.Backcolor = color.black
end select
you see the work to save all the properties !!!!
I will check then saving the objects properties in a dat file with a record structure of object properties.
Patrice
|
|
|
|
|
maybe your right about ignoring the registry... idon't know...
if you got sur let me notice.
about the color ...
your can save the color to a string using ToArgs...
like:
str= listview1.backcolor.color.ToArgs
and get it back by
listview1.backcolor.color.fromArgs=str
i don't remember the right syntax by check it out
militiaware...........Faris Madi
|
|
|
|
|
Thanks Faris,
ToArgb doesn't exactly fit to my idea but is closest.
In fact I am working arround with :
ListView1.BackColor = Color.FromName("black") '// <-- accept strings
ListView1.Font = New Font("Arial", 8, 2, 0, 0) '// <-- also accept strings or values
or something like that.
The problem I have is that
sw.WriteLine(ListView1.ForeColor)
sw.WriteLine(ListView1.BackColor)
sw.WriteLine(ListView1.Font)
may give a variable number of values if the color is not named but selected custom that give instead three numbers.
|
|
|
|
|
Colors can be saved as a binary Argb representaion which describes the color as an integer value. Color objects can be recreated from the same binary value. You don't need to worry about strings or cases - just save and restore the binary representation of the color.
|
|
|
|
|
Ok then, will look at this further. I have found a solution resticted to the named colors that works properly.
Of course if we are using the custom colors provided by the ColorDialog control, then the use the ARGB parameters is probably the best idea.
And to save the fonts, have you any suggestion ?
Thanks for your help.
Pat
|
|
|
|
|
ARGB works for all colors I would use it in any case. As far as saving fonts, whether you use the Registry, and INI file, text file etc is up to you. The process is always the same - you have to save enough parameter values to recreate the font - Family, Style, Size, Color, etc
|
|
|
|
|
Well, saving all the font parameters looks easy to write in a single sentence:
recreate the font - Family, Style, Size, Color.
It would have been nice to have something like: ListView1.Font.ToString
ListView1.Font.FromString
What we have handy is more confusing :
assuming you have open sw as streamwriter
sw.WriteLine(ListView1.Font) writes :
[Font: Name=Times New Roman, Size=15,75, Units=3, GdiCharSet=0, GdiVerticalFont=False]
sw.WriteLine(ListView2.Font.Size) can give : 9,75 or 12
Question : how can we restore(well simply) a font size defined by : 10 12 9,75 or 15,75 ?
The only way I find is to parse the written string and analyse to look if we have a ',' in the size
and then convert it in 15.75
pfff!
Best Regards
Pat
|
|
|
|
|
So guys, with your help I have got it working pretty nice.
To put it all together and to clean up the table, for those interested:
How to save and restore fonts and colors from controls: (if there is a better way to do it just tell)
' Saving the parameters<br />
Dim sw As New StreamWriter("myInitFile.ini")<br />
' Color of Caracters<br />
sw.WriteLine(RichTextBox1.ForeColor.ToArgb)<br />
sw.WriteLine(ListView1.ForeColor.ToArgb)<br />
' Color of Background<br />
sw.WriteLine(RichTextBox1.BackColor.ToArgb)<br />
sw.WriteLine(ListView1.BackColor.ToArgb)<br />
'Fonts<br />
sw.WriteLine(RichTextBox1.Font.Name)<br />
sw.WriteLine(ListView1.Font.Name)<br />
'Size<br />
sw.WriteLine(RichTextBox1.Font.SizeInPoints)<br />
sw.WriteLine(ListView1.Font.SizeInPoints)<br />
sw.close()<br />
<br />
' retriving the parameters<br />
Dim sr As New StreamReader("myInitFile.ini")<br />
delimStr1 As String = "[] :,.=;"<br />
Dim delimiter As Char() = delimStr1.ToCharArray()<br />
Dim split As String() = Nothing<br />
Dim i, Pos, First As Integer<br />
Dim Words, s As String<br />
Dim token(16) As String<br />
For i = 1 To 6<br />
token(i) = sr.ReadLine<br />
Next i<br />
Pos = 6<br />
For i = 1 To 2<br />
Words = sr.ReadLine<br />
split = Words.Split(delimiter)<br />
Pos += 1<br />
First = 0<br />
For Each s In split<br />
If s <> "" Then<br />
First += 1<br />
If First = 1 Then<br />
token(Pos) = s<br />
End If<br />
End If<br />
Next s<br />
Next i<br />
<br />
RichTextBox1.ForeColor = Color.FromArgb(CInt(Val(token(1))))<br />
ListView1.ForeColor = Color.FromArgb(CInt(Val(token(2))))<br />
RichTextBox1.BackColor = Color.FromArgb(CInt(Val(token(3))))<br />
ListView1.BackColor = Color.FromArgb(CInt(Val(token(4))))<br />
RichTextBox1.Font = New Font(token(5), CShort(Val(token(7))))<br />
ListView1.Font = New Font(token(6), CShort(Val(token(8))))<br />
sr.close()<br />
That's all folks!
This is a simplified extract of my program which work nice. This is my little contribution and thanks your help.
Best regards
Patrice
|
|
|
|
|
One comment. There are APIs that allow reading and writing INI file without having to parse them line by line. For example, you can simply call a function to read or write a certain value from a specific key and section.
I created a module that wraps the apis in simple function calls. If you want a copy, send me your e-mail and I will send it to you.
|
|
|
|
|
What is the fastest way to push data to Excel?
I am iterating through an array and putting the data into excel using the activecell.offset. This takes forever for any reasonable amount of data. I am pushing data from a syncfusion grid; any clever tracks I could do??
|
|
|
|
|
I have a VBA app that exports the activesheet to an xml file. I know that app.config files are just another form of XML files. How can I get this app to export to .config files as well? I am using
ActiveWorkbook.XmlMaps("ConfigParameters_Map").Export to export the data to an XML file. Thanks in advance.
P
|
|
|
|
|
I have upwards of 60 controls on an asp.net page, a little under half being checkboxes, a little under half being labels, and a few textboxes. Going through manually and clearing them if a giant pain, and I know there has to be an efficient way to clear them, like using a For Each loop, checking the type of control, then taking the appropriate action (ie. .Check = false, .Text = "", etc). Problem is I'm pretty new to the .Net framework and I'm not exactly sure how to reference the controls.
Any ideas? Thanks in advance.
-------------------
>abort, retry, fail?
|
|
|
|
|
Hello!...
try this one..........I am considering that you have these all these controls in some parent control like GroupBox.
Here is the code
Dim ctrl As Control
For Each ctrl In GroupBoxName.Controls
ctrl.Text = ""
Next
Now for differentiating b/w the controls say Textbox and Checkbox etc it would be very easy if you have some meaningful control names e.f textbox name starts with 'txt' and checkbox with 'chk' or whatever......If this is so then you can check for the control names for finding out the type of control.......
I hope this will solve ur problem
_mubashir
Marriala Technologies,
Pakistan.
|
|
|
|
|
Thanks for the input! I'm one step closer, but not quite there...
Actually, they're inside in an HTML table inside a Form. I'm pretty close with the logic, I just can't seem to finagle the reference to the form correctly. Here's what I have:
Dim ctrl As Control<br />
For Each ctrl In Page.Form1<br />
If TypeOf ctrl Is CheckBox Then<br />
CType(ctrl, CheckBox).Checked = False<br />
End If<br />
If TypeOf ctrl Is Label Then<br />
CType(ctrl, Label).Text = ""<br />
End If<br />
If TypeOf ctrl Is TextBox Then<br />
CType(ctrl, TextBox).Text = ""<br />
End If<br />
Next
the Page.Form1 is what it's getting caught up on.
Any ideas?
abort, retry, fail?
|
|
|
|
|
got it!
the reference is: Page.Controls.Item(1).Controls
Item(1) being the form.
thanks for your help!
abort, retry, fail?
|
|
|
|
|
Hi a newbee question, is it possible to disable the rigt click of the contextmenu control. i whould like to use a command button to fire the contextmenu instead of the right click, is it. Thank u all Andy38
|
|
|
|
|
Hi everyone, I'm a new member of this wonderfull community.I have got many answers to my problems in you community. I am a beginner in Visual Studio.NET, I lately used Visual Basic 6.0 in programming. But I want to still master Visual BAsic 6.0 but, my problem is I dont want to use Pirated Visual Studio just to program in Visual Basic 6.0. I just want to ask help from your community if you know free IDE for Visual Studio 6.0.I will really appreciate if you help me with this, because I believe that piracy is not accepted in IT.thanks a lot...hope to hear from you guys! thanks.....
yoks
|
|
|
|