Home | Index | Dotnet4all Snippets | Submit resources
About | Mail us 
How to bind a combobox to a DataSet? (Wednesday, January 11, 2006)

Found the following interesting discussion in the Newsgroups:

Binding a combobox to a DataSet
by:Tom

I have a dataset called "employees" with a field
called "gender". How do I bind a combobox to it so that
the user is only allowed to select "M" or "F" and that
value ends up in the dataset?
Note that M and F are not in a table of a database. I
have entered them directly into the Items collection of
the combobox via the property editor.

Thanks


 Reply:
by:Cor Ligthert

 Hi Tom,


What is than in the database? While I would not use a combobox for that, for
the user is a checkbox (male) or even better (but some more work) two
radiobuttons

Cor


 Reply:
by:Tom

 The database has a text field with M or F in it. This is
just one example. I also have a state field for which I
have a combo box that shows the 50 state codes. So I
actually do want to use a combobox. I had used a textbox
in the past and thought this would be a nice improvement.
combobox for that, for
more work) two


 Reply:
by:Cor Ligthert

 Hi Tom,

A little bit crazy sample.

However it works, because I did not use any events I use an extra textbox to
show the behaviour, it needs a project with draged on 3 textboxes, a
combobox and a listbox and this pasted in the code. You can let it go using
the listbox.

I hope this helps?

Cor

\\Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable
dt.Columns.Add("Id")
dt.Columns.Add("Gender")
For i As Integer = 0 To 10
Dim dr1 As DataRow = dt.NewRow
Dim dr2 As DataRow = dt.NewRow
dr1(1) = "M"
dr2(1) = "F"
dr1(0) = i.ToString
dr2(0) = i.ToString & i.ToString
dt.Rows.Add(dr1)
dt.Rows.Add(dr2)
Next
Dim dc As New DataTable
dc.Columns.Add("M/F")
dc.Columns.Add("Gender")
Dim dra As DataRow = dc.NewRow
Dim drb As DataRow = dc.NewRow
dra(1) = "M"
drb(1) = "F"
dra(0) = "Male"
drb(0) = "Female"
Me.ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
dc.Rows.Add(dra)
dc.Rows.Add(drb)
Me.TextBox1.DataBindings.Add("text", dt, "Id")
Me.ComboBox1.DataBindings.Add("SelectedValue", dt, "Gender")
Me.ComboBox1.DataSource = dc
Me.ComboBox1.ValueMember = "Gender"
Me.ComboBox1.DisplayMember = "M/F"
Me.TextBox2.DataBindings.Add("text", ComboBox1, "SelectedValue")
Me.TextBox3.DataBindings.Add("text", dt, "Gender")
Me.ListBox1.DataSource = dt
Me.ListBox1.DisplayMember = "Id"
End Sub
///


 Reply:
by:

 I tried your code and it worked, but it wasn't exactly
what I was looking for. I had created the combobox almost
completely through the visual interface and had used the
Items property to save a list of the possible values. I
had then bound it to my dataset by binding the text
property. This did not properly save the selected value
to the dataset. It turns out it worked properly when
instead I bound the selecteItem property to the dataset.
Why that is, I don't know, but it works.

Thanks for the help. Your example (and a bit more
reading) helped me understand databinding a little better.
Tom



Posted by Xander Zelders
0 Comments



Export Crystal Reports

Found the following interesting discussion in the Newsgroups:

Export Crystal Reports
by:Ahmed Hashish

Dear Sir
How could I export a crysatl report to html format on webforms

Ahmed


 Reply:
by:Anonymous

 Export functions

Excel

Dim crReportDocument As BudgetActualRevenues
crReportDocument = New BudgetActualRevenues()
CrystalReportViewer1.ReportSource = crReportDocument
CrystalReportViewer1.Visible = True
CrystalReportViewer1.ReportSource = crReportDocument
Dim excelFormatOpts As New ExcelFormatOptions()
Dim diskOpts As New DiskFileDestinationOptions()
' Set the excel format options.
excelFormatOpts.ExcelTabHasColumnHeadings = True
excelFormatOpts.ExcelUseConstantColumnWidth = False
excelFormatOpts.ExcelConstantColumnWidth = "200"
crReportDocument.ExportOptions.ExportFormatType = ExportFormatType.Excel
crReportDocument.ExportOptions.FormatOptions = excelFormatOpts
' Set the disk file options and export.
crReportDocument.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
diskOpts.DiskFileName = "C:\folderName\FolderName\Report.xls"
crReportDocument.ExportOptions.DestinationOptions = diskOpts
crReportDocument.Export()

PDF

Dim crReportDocument As Confirmation
crReportDocument = New Confirmation()
'Export to PDF
Dim excelFormatOpts As New CrystalDecisions.Shared.ExportOptions()
Dim diskOpts As New DiskFileDestinationOptions()
diskOpts.DiskFileName = "C:\folderName\Report.xls"
crReportDocument.ExportOptions.DestinationOptions = diskOpts
crReportDocument.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
crReportDocument.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
crReportDocument.Export()

' Read export file
Dim myEXportfile As String = "C:\folderName\Report.pdf"
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(myEXportfile)
Response.Flush()
Response.Close()
Remove file
System.IO.File.Delete(myEXportfile)
You should be able to use this to find the HTML Export



Posted by Xander Zelders
0 Comments



Convert VB 6 ActiveX control to .net

Found the following interesting discussion in the Newsgroups:

Convert VB 6 ActiveX control to .net
by:Mike Kanski

Which project type should i work in vb.net in order for me to rewrite vb 6
activex control to vb.net?
The control is very simple, should run in the browser.


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 

J# Browser Controls provide developers with a way to migrate their existing
Java applet source code to run within the context of the .NET Framework

<URL:http://www.microsoft.com/downloads/details.aspx?FamilyID=325a8f15-fe7b-4087-aa46-6d3e1b6108e0>

MSDN documentation link:

<URL:http://msdn.microsoft.com/library/en-us/dv_vstechart/html/vjtskMigratingJavaAppletsToMicrosoftJBrowserControls.asp>

For .NET 1.0, controls as ActiveX are only supported hosted in MSIE 5+6:

<URL:http://support.microsoft.com/?scid=kb;EN-US;311334>
<URL:http://support.microsoft.com/?scid=kb;EN-US;317346>

Using Windows Forms Controls in Internet Explorer:

<URL:http://msdn.microsoft.com/msdnmag/issues/02/06/rich/rich.asp>

--
Herfried K. Wagner



Posted by Xander Zelders
0 Comments



When to dispose?

Found the following interesting discussion in the Newsgroups:

When to dispose
by: Just Me

I've been disposing whenever I create a bitmap or graphics object.

Recently I developed a bug which turned out to be as follows:

bmp=new Bitmap(...
picBox.Image = bmp
..
..
bmp.dispose
exit sub

Now I can see that Image is pointing to a disposed bitmap.
But if I don't will picturebox dispose the bitmap assigned to Image?

Do I have to assign to Image or can I just draw on it.

What happens if I never dispose of my Graphic or Bitmap objects?

Thanks in advance for any answers


 Reply:
by:Anonymous

 1) You should dispose of the Image (in this case) not the Bitmap.
2) Not sure what you mean by Assign to Image or Just Draw to it. You have to have the object (an Image) in memory before you can update it (by drawing to on it.)
3) If you do not dispose of your Graphics or Bitmaps, most likely you will be fine, but if you are creating huge numbers of them you may run out of memory or other resources. The GC "should" take care of them, but I have found that it is much bertter to dispose of them once you are done with them. As is always the case, your application design will dictate.

HTH
--
David Williams


 Reply:
by: Just Me

 
news:56E7DE5E-7110-45D0-950E-A94B3AA56464@microsoft.com...
Now that's confusing. Doesn't the PictureBox need to have the Image as long
as it is displaying?
Or do I dispose the image when the Picturebox is closing?

Is it better to
Dim zz As Graphics = PictureControl1.PicCreateGraphics
zz.DrawImage(Img, 0, 0)

or is it better to

picBox.Image = Img

You have to have the object (an Image) in memory before you can update it
(by drawing to on it.)

Meaning I can't do the first above before I do the second - right?

be fine, but if you are creating huge numbers of them you may run out of
memory or other resources. The GC "should" take care of them, but I have
found that it is much bertter to dispose of them once you are done with
them. As is always the case, your application design will dictate.

There's no association between these disposes and deleting handles in
windows API (which as I remember MUST be done)?
Thanks a lot for all the info!



Posted by Xander Zelders
0 Comments



How to start a remote process?

Found the following interesting discussion in the Newsgroups:

Starting a remote process
by:Ronan

Does anybody knows how can I execute a process from one machine in another
one?
For example:
I´m executing a "From.exe" file in a machine A, and the code of
the machine B now have a process called "To.exe" running.
Is that possible?

Thanks!!!
Ronan


 Reply:
by:Anonymous

 Basically it's client/server architecure. Machine B should have a application (ex, windows service) to listen to command from Machine A. The application can start other process after received command.





Posted by Xander Zelders
0 Comments



Screen Scraping With VB.NET

Found the following interesting discussion in the Newsgroups:

Screen Scraping With VB.NET
by:Nick

What i wanted to do is make a webgame easyer, by getting
the page, and in stead of having multiple click actions,
make it all just 1 click and record stats for my profile.

For Example:

there is an arm wrestle part, you have to select oponent,
and click Challenge, because of the high traffic, once
you click challenge, the match is allready over, and u
have to refresh the page and try another.

The problem however is: when i make a webrequest, i only
get:
[Response]

<script type="text/javascript">
if (self.name != 'right')
top.location.replace('index.php');
</script>

<META HTTP-EQUIV="Refresh" CONTENT="0; URL=index.php"
TARGET="_top">

[/Response]

added a response bracket to show what i got from the page.

I wonder what headers i need to set to get the full page,
when i use IE, and do Show Source, i get much more (will
show in the bottom of the post.)

Here's the code i had to get the response:

[Code]

Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
txtAW.Text = getpage
("http://www.bootleggers.us/index.php")
End Sub

Private Function getpage(ByVal url As String) As
String
Dim awPR As System.Net.HttpWebRequest = CType
(System.Net.WebRequest.Create(url),
System.Net.HttpWebRequest)
Dim awResp As System.Net.WebResponse
awPR.Headers.Add("name", "right")
Try
awResp = awPR.GetResponse
Catch ex As Exception
MsgBox(ex.Message)
Exit Function
End Try
Dim r As New System.IO.StreamReader
(awResp.GetResponseStream())
Dim strTmp As String = r.ReadToEnd
r.Close()
Return strTmp
End Function

[/Code]

Thanx in Advance,

Nick

Response i should get:

<script type="text/javascript">
if (self.name != 'right')
top.location.replace('index.php');
</script>
<html>
<head>
<link REL="stylesheet" TYPE="text/css"
HREF="includes/main.css">
</head>
<body bgcolor=#333333>
<head>
<link REL=\"stylesheet\" TYPE=\"text/css\"
HREF=\"http://www.bootleggers.us/includes/main.css\">
</head>

<body topmargin=0>
<table width="100%" border=0 cellpadding=0 cellspacing=0
bgcolor="#5C5C5C">
<tr><td><img src="http://www.bootleggers.us/l.gif"></td>
<td width="100%"
background="http://www.bootleggers.us/m.gif"></td>
<td><img src="http://www.bootleggers.us/r.gif"></td>
</tr>
</table>
<br><br>

<center>
<table width=90% cellspacing=0 cellpadding=0 border=0>
<tr>
<td width=50% valign=top align=center>

<form method=post action=>
<table border=1 cellspacing=0 cellpadding=2
bordercolor=black width=90% class=sub2>
<tr>
<td class=header align=center colspan=3>Train</td>
</tr>
<tr>
<td class=header align=center>Activity</td>
<td class=header align=center>Rest</td>
<td class=header align=center>Gain</td>
</tr>
<tr>
<td width=50%><input type=radio name=train value=1> 10
Pullups</td>
<td>10 Mins</td>
<td>13%</td>
</tr>
<tr>
<td width=50%><input type=radio name=train value=2> 15
Dumbbells</td>
<td>5 Mins</td>
<td>7%</td>
</tr>
<tr>
<td width=50%><input type=radio name=train value=3> 25
Pushups</td>
<td>2 Mins</td>
<td>3%</td>
</tr>
<tr>
<td colspan=3 align=right><input type=submit
value="Work Out!"></td>
</tr>
</table>
</form>

<br>

<table border=1 cellspacing=0 cellpadding=2
bordercolor=black width=90% class=sub2>
<tr>
<td class=header align=center colspan=3>Current
Strength</td>
</tr>
<tr>
<td width=45%>Wins/Losses Ratio:</td><td>466:90</td>
</tr>
<tr>
<td width=45%>Current Level:</td><td>29</td>
</tr>
<tr>
<td width=45%>Percent to Next Level:</td>
<td>
<table border=0 cellspacing=0 cellpadding=0
width=100% class=sub2>
<tr><td width=36% bgcolor=green
align=right> </td><td>36%</td>
</tr>
</table>
</td>
</tr>
</table>

<br><br>

<form method=post action=>
<table border=1 cellspacing=0 cellpadding=2
bordercolor=black width=90% class=sub2>
<tr>
<td class=header align=center colspan=3>Create
Match</td>
</tr>
<tr>
<td>Bet:</td><td><input type=text name=matchbet></td>
</tr>
<tr>
<td> </td><td align=right><input type=submit
value="Start!"></td>
</tr>
</table>
</form>


</td>
<td width=50% valign=top align=center>

<form method=post action=>
<table border=1 cellspacing=0 cellpadding=2
bordercolor=black width=90% class=sub2>
<tr>
<td class=header align=center colspan=4>Current
Matches</td>
</tr>
<tr>
<td class=header align=center width=1%> </td>
<td class=header align=center>Opponent (W:L)</td>
<td class=header align=center>Bet</td>
</tr>
<tr>
<td width=1%><input type=radio name=challengematch
value="7470"></td>
<td><a href="viewprofile.php?
viewuser=Aronovic">Aronovic</a> (193:571)</td>
<td>$150</td>
</tr>
<tr>
<td width=1%><input type=radio name=challengematch
value="7471"></td>
<td><a href="viewprofile.php?
viewuser=luckchris">luckchris</a> (45:153)</td>
<td>$111</td>
</tr>
<tr>
<td width=1%><input type=radio name=challengematch
value="5531"></td>
<td><a href="viewprofile.php?
viewuser=Rikskie">Rikskie</a> (1421:110)</td>
<td>$1,624,032</td>
</tr>
<tr>
<td width=1%><input type=radio name=challengematch
value="7392"></td>
<td><a href="viewprofile.php?viewuser=swipe">swipe</a>
(2838:399)</td>
<td>$150</td>
</tr>
<tr>
<td colspan=4 align=right><input type=submit
value="Challenge!"></td>
</tr>
</table>
</form>

</td>
</tr>
</table>
</center><br><br><center>
<table border=1 cellspacing=0 cellpadding=2
bordercolor=black class=sub2>
<tr>
<td><b>Crew:</b> None</td>
<td><b>Rank:</b> Boss</td>
<td><b>Cash:</b> $333,161</td>
<td><b>Health:</b><td bgcolor=green width=100
align=center>100%</td><td class=sub2 width=0
align=center> </td></td>
</tr>
<tr>
<td colspan=2><b>Gun:</b> HighStandard .22 (0
Bullets)</td>
<td colspan=4><b>Protection:</b> None </td>
</tr>
</table>

<br>

<a
href="http://www.bootleggers.us/agreement.php">Terms of
Service</a>
</center>


 Reply:
by:Nick

 i only added this below here, to try if that made anny
difference, but as u might be able to tell, i am kindda
lost...
awPR.Headers.Add("name", "right")



Posted by Xander Zelders
0 Comments



Determine Packets sent and received on computer

Found the following interesting discussion in the Newsgroups:

Determine Packets sent and received on computer
by:Brian

Hello,

As the subject says is there an api the will allow me to view the packets
sent/received just like the icon for the network properties? Any links,
examples are appreciated.

Brian


 Reply:
by:Arne Janning

 Brian wrote:


Hi Brian,

http://www.codeproject.com/dotnet/dotnetwinpcap.asp

This might help.

Cheers

Arne Janning


 Reply:
by:Brian

 Thanks Arne,

I'll check it out.

Brian



Posted by Xander Zelders
0 Comments



TabControl Question

Found the following interesting discussion in the Newsgroups:

TabControl Question
by:Richard

Hi,

Simple tabcontrol question:

I have a tab control with a number of tabpages on it. What I want is to
show a particular tabpage when I click a button that is not on the
tabcontrol. Can anyone tell me how I would code this?

Thanks
Richard


 Reply:
by:Greg Burns

 Here is some code I have that does that.

I have four checkboxs across the top (appearance properties = Button). When
you check/depress the button, it shows corresponding Tabpage. When no
buttons are pressed, TabControl is hidden:

Good luck,
Greg
' class level variables
Private _tabs(3) As TabPage

' the names of my 4 tabs...
Enum TabNames
Changes
Transfer
Leave
Term
End Enum
Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call
TabControl1.TabPages.Clear()
TabControl1.Visible = False ' hide by default
End Sub

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles CheckBox1.CheckedChanged

ShowHideTab(TabNames.Changes)

' light the button up when pressed...
If CheckBox1.CheckState = CheckState.Checked Then
CheckBox1.ForeColor = Color.White
CheckBox1.BackColor = Color.Green
CheckBox1.Font = New Font(Me.Font.Name, Me.Font.Size,
FontStyle.Bold)
Else
CheckBox1.ForeColor = SystemColors.ControlText
CheckBox1.BackColor = SystemColors.Control
CheckBox1.Font = Nothing
End If

End Sub

Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged

ShowHideTab(TabNames.Transfer)

If CheckBox2.CheckState = CheckState.Checked Then
CheckBox2.ForeColor = Color.White
CheckBox2.BackColor = Color.Green
CheckBox2.Font = New Font(Me.Font.Name, Me.Font.Size,
FontStyle.Bold)

Else
CheckBox2.ForeColor = SystemColors.ControlText
CheckBox2.BackColor = SystemColors.Control
CheckBox2.Font = Nothing

End If
End Sub

Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
ShowHideTab(TabNames.Leave)

If CheckBox3.CheckState = CheckState.Checked Then
CheckBox3.ForeColor = Color.White
CheckBox3.BackColor = Color.Green
CheckBox3.Font = New Font(Me.Font.Name, Me.Font.Size,
FontStyle.Bold)

Else
CheckBox3.ForeColor = SystemColors.ControlText
CheckBox3.BackColor = SystemColors.Control
CheckBox3.Font = Nothing

End If
End Sub

Private Sub CheckBox4_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles CheckBox4.CheckedChanged

ShowHideTab(TabNames.Term)

If CheckBox4.CheckState = CheckState.Checked Then
CheckBox4.ForeColor = Color.White
CheckBox4.BackColor = Color.Green
CheckBox4.Font = New Font(Me.Font.Name, Me.Font.Size,
FontStyle.Bold)

Else
CheckBox4.ForeColor = SystemColors.ControlText
CheckBox4.BackColor = SystemColors.Control
CheckBox4.Font = Nothing

End If

End Sub

Private Sub ShowHideTab(ByVal i As TabNames)

If _tabs(i) Is Nothing Then
Me.Cursor = Cursors.WaitCursor

TabControl1.Visible = True
Select Case i
Case TabNames.Changes

_tabs(TabNames.Changes) = TabPage1
SortTabPages(TabPage1)

Case TabNames.Transfer

_tabs(TabNames.Transfer) = TabPage2
SortTabPages(TabPage2)
Case TabNames.Leave

_tabs(TabNames.Leave) = TabPage3
SortTabPages(TabPage3)

Case TabNames.Term

_tabs(TabNames.Term) = TabPage4
SortTabPages(TabPage4)

End Select

Me.Cursor = Cursors.Default
Else
_tabs(i) = Nothing
Select Case i
Case TabNames.Changes
TabControl1.TabPages.Remove(TabPage1)
Case TabNames.Transfer
TabControl1.TabPages.Remove(TabPage2)
Case TabNames.Leave
TabControl1.TabPages.Remove(TabPage3)
Case TabNames.Term
TabControl1.TabPages.Remove(TabPage4)
End Select

If TabControl1.TabCount = 0 Then
TabControl1.Visible = False
End If
End If

End Sub

Private Sub SortTabPages(ByVal currentTab As TabPage)
' To reorder the tabs, clear the collection and add them again

TabControl1.TabPages.Clear()
For Each tab As TabPage In _tabs
If Not tab Is Nothing Then
TabControl1.TabPages.Add(tab)
End If
Next

TabControl1.SelectedTab = currentTab
End Sub


 Reply:
by:Richard

 Thanks Greg, that was just what I wanted.



Posted by Xander Zelders
0 Comments



Controls Problem

Found the following interesting discussion in the Newsgroups:

Controls Problem
by:Gigaworld

I have this PROBLEM with controls collection:

The old VB 6.0 syntax was:

MyStr = me.controls("button1").text

VB .NET doesn't function in this way, because in .NET
I must know the index of the control! I need to use the
STRING NAME of the control to address the object, because
my target is doing something like this:
for i = 1 to 10
MyStr(i) = me.controls("button" & i ).text
next i
if I use this:

MyStr = me.controls(IndexOf(button1)).text

I have again the same problem: cannot use the STRING NAME
of the object!


 Reply:
by:Supra

  u used this ....

MyStr(i) = me.controls.text.substring("blah" & i) or u can used tostring(..)
or u can do stringbuilder.
kindly read book. recommended microsoft press book. or search in google

index is no longer in vb.net.
regards


 Reply:
by:One Handed Man \( OHM - Terry Burns \)

 Dim found as Boolean = False
Dim c as Control
For each c in form.controls

if c.name="YourControlName" Then
Found=true
Exit Next
End IF

Next

If Found then ' c point to your control so . . .

'..... Do Stuff ......

End If

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing


 Reply:
by:Anonymous

  Dim myStr As String
Dim myControl As Control
For Each myControl In Me.Controls
If TypeOf myControl Is Button AndAlso myControl.Name = "button1" Then
myStr = myControl.Text
Exit For
End If
Next



 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 
[...]

No multiposts please!

--
Herfried K. Wagner



Posted by Xander Zelders
0 Comments



What to do with VB.net?

Found the following interesting discussion in the Newsgroups:

What to do with VB.net
by:Anonymous

Now I swear i made this topic yesterday but i can t find so if it does exsist plz tell me but i'll make again here anyway.
I'm a new to VB.net and barely know anything about VB.net, so far all i've done is made a small calculator that adds and subtracts. Does anyone have any ideas for what I can do that is really easy. Thanks



 Reply:
by:Cor Ligthert

 Hi Tom,

Yes download the resource kit of have a look at the quickstarts

VB.net Resource kit
http://msdn.microsoft.com/vbasic/vbrkit/default.aspx

And if you have problems installing the resource kit
http://msdn.microsoft.com/vbasic/vbrkit/faq/#installvdir

Another resource for learning is the Quick Starts
http://samples.gotdotnet.com/quickstart/

I hope this helps a little bit?

Cor


 Reply:
by:One Handed Man \( OHM - Terry Burns \)

 Tom,
I would recommend you buy the .NET core requirements book from
PC-world. This is a self paced tutorial to get you up to MCSD level through
a series of exams. Even if you dont want to take the exams, its an excellent
guide.

It costs around 125 quid , but its worth it. If this is too much for you,
try one of the excellent range of SAMS books.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing


 Reply:
by:Ricky W. Hunt

 
news:22D5F30A-8507-4344-842C-6457966BAF3D@microsoft.com...
exsist plz tell me but i'll make again here anyway.
done is made a small calculator that adds and subtracts. Does anyone have
any ideas for what I can do that is really easy. Thanks

Tom,

I've just started in the last week or so but here's some good stuff I've
found:

http://www.startvbdotnet.com/

http://www.programmingtutorials.com/vbnet.aspx

http://www.learnvisualstudio.net/default.aspx

And of course:
http://www.google.com/search?hl=en&ie=UTF-8&q=%22visual+basic%22+%22.net%22+tutorial


 Reply:
by:cyn_lau@online_microsoft.com (Cynthia Lau[MSFT])

 Also try this tutorial site:
http://samples.gotdotnet.com/quickstart/

Thanks,
Cynthia



Posted by Xander Zelders
0 Comments



Retrive type of file

Found the following interesting discussion in the Newsgroups:

Retrive type of file
by:Xavier Valdés

Hi all,

I'm using SHGetFileInfo api call from VB.NET so as to retreive icon
associated of a file. I want also to get "type of file" string with
SHGFI_TYPENAME flag but I can't see nothing. When I call api function and I
look for szTypeName all I get is a null string.
Any help?
Thanks a lot,
Xavier


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 

Quick and dirty:

\\Imports System.Runtime.InteropServices

Public Class Form1
Inherits System.Windows.Forms.Form

Private Declare Auto Function SHGetFileInfo Lib "shell32.dll" ( _
ByVal pszPath As String, _
ByVal dwFileAttributes As Integer, _
ByRef psfi As SHFILEINFO, _
ByVal cbFileInfo As Integer, _
ByVal uFlags As Integer _
) As IntPtr

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> _
Private Structure SHFILEINFO
Public hIcon As Int32
Public iIcon As Int32
Public dwAttributes As Int32
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> _
Public szDisplayName As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)> _
Public szTypeName As String
End Structure

Private Const SHGFI_TYPENAME As Int32 = &H400

Private Sub Form1_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles MyBase.Load
Dim x As SHFILEINFO
Call SHGetFileInfo("C:\test_tl\ausarb.tex", 0, x, Len(x), SHGFI_TYPENAME)
MsgBox(x.szTypeName)
End Sub
End Class
///

--
Herfried K. Wagner


 Reply:
by:Xavier Valdés

 Thank you very much!
That's perfect!



Posted by Xander Zelders
0 Comments



GridView Row Filter Method

Found the following interesting discussion in the Newsgroups:

GridView Row Filter Method
by:Eligio F. Villanueva

I tried to filter my grid data with this:

DataView.Rowfilter = "dblAmount LIKE '6%'"

and there message appears:


Is there another way to solve this?

Thanks!


 Reply:
by:Cor Ligthert

 



Posted by Xander Zelders
0 Comments



DataView Row Filer Method

Found the following interesting discussion in the Newsgroups:

DataView Row Filer Method
by:Eligio F. Villanueva



I tried to filter my grid data with this:

Dataview.RowFilter = "dblAmount LIKE '6%'"

and this message comes out:


Is there a way that i could filter the value of my amount?
Thanks!


 Reply:
by:Cor Ligthert

 HI Eligio,

This looks clear to me.
You ask it your amount has something like the text 6%

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatacolumnclassexpressiontopic.asp

I think that with this description it is easy to correct it by you.

I hope this helps?

Cor



Posted by Xander Zelders
0 Comments



EventLog.Source & Service Programs

Found the following interesting discussion in the Newsgroups:

EventLog.Source & Service Programs
by:irreverence2381@hotmail.com (MAL)

Hello,

I am writing a service program that writes to a custom EventLog. I
would like the two classes used in the service to write messages to
the same log ideally using a different Source name for filtering etc.

So far I am having little luck. I feel that I have been through the
documentation extensively but am chasing my tail. It seems like it
should be as simple as .CreateEventSource in each class I want to
write to the custom log, but to no avail.

When I tried to just add one class to the service program, the service
program wrote to the Application Log and the class wrote to the custom
one, even though the service seemed to have created the log. (Based on
a 5 minute timer before "Newing" my class) (.AutoLog = False) The code
is straight from the service program and EventLog walkthroughs (which
I end up using to clean things up (RemoveSource(s), DeleteLog) before
my next service removal and reboot.

The last thing I tried was creating a seperate EventLog in each class
and trying to associate the source with the log the service created. I
have attemted to pass a reference to the EventLog to the classes and
then change the source like in the multithreaded examples. I have
tried to bring the service pgms EventLog into scope in the classes.
AHHHHHHH!!!

I am obviously making this harder that it needs to be.

Thanks for reading this rant. Please advise.


 Reply:
by:David Williams , VB.NET MVP

 In your OnStart function:

Dim log As EventLog

If Not EventLog.SourceExists("ServiceSourceNameOfYourChoice") Then
EventLog.CreateSource("ServiceSourceNameOfYourChoice")
End If
log = New EventLog("Application", "ServiceSourceNameOfYourChoice")

HTH

David Williams



Posted by Xander Zelders
0 Comments



UBound - DataSet Less - DataGrid (Tuesday, January 10, 2006)

Found the following interesting discussion in the Newsgroups:

UBound - DataSet Less - DataGrid
by:rawCoder

Hi There,

I simply want a DataGrid in .NET which acts .. well like the old VB6 grid
.... where you fill and access elements directly ... not being dependant on
some data source or DataSet to be more precise.

IOW need a perfectly UnBound DataGrid elements of which can be
added/accessed/modified using simple .Rows and .Columns

Thank You,
rawCoder


 Reply:
by:Shakir Hussain

 If you need a unbound datagrid, you have to use DataTable class.

Example

//create a new data table
DataTable dgTable = new DataTable();

//lets create one column
DataColumn dgCol = new DataColumn();
dgCol.DataType = System.Type.GetType("System.String");
dgCol.Caption = "Names";
dgCol.ColumnName = "ColName";

//add column to data table
dgTable.Columns.Add(dgCol);

//lets create a row
DataRow dgRow = new DataRow();
dgRow["Names"] = "My Name";

//add row to data table
dgTable.Rows.Add(dgRow);

//set data table as datasource in the data grid
dataGrid1.DataSource = dgTable;

Shak


 Reply:
by:rawCoder

 Thanx Shakir and Cor

But you see what i meant by UnBound and Dataset Less grid was that i dont
need the inclusion of any DataSet / DataTable / DataColumn / DataRow /
DataView ... nothing .

All i need is simple grid with data accessible Cell By Cell rather than
record based.

Actually i have certain need for which i want this and i am thinking of
writing a wrapper that does so.

Has someone written a wrapper over it.

Thanx anyways
rawCoder


 Reply:
by:Cor Ligthert

 Hi RawCoder,

Why? You can simple make a datatable which acts perfectly as the datasource
for a datagrid with what you get a perfectly a not databasebound datagrid
(of couse with one table, with more you need a combined datatable so a
dataset, which is to make as well very easy without a database of course).

I think that it would be even possible to make an own userdatagrid with that
however I see no reason for that.

However when you are not looking for that, forgive me for interrupting this.

Cor



Posted by Xander Zelders
0 Comments



Inheiritance of a from WITH a dataset

Found the following interesting discussion in the Newsgroups:

Inheiritance of a from WITH a dataset
by:Gary Shell

I have jumped in to the deep end of the pool, trying out visual inheritance
of a form and have run into a snag.

I have the need to create a simple maintenance form for five identically
configured database files. (The only difference in the tables is their name
and keyfield name.) Hmmm, I though, a perfect candidate for trying our
Visual Inheritance for the first time. ARGHHHHHHH! What have I gotten
myself into?

Here's the specifics. I created a form and saved it as a class. I am able
to then create a form that inherits my original. That part works great. I
was even able to add a couple of Protected Strings to the base form and in
the Public Sub New routine of the one of the real forms I added code to set
the two protected strings to reflect the Table name and Key name. The form
load event in the base form uses these strings to dynamically create the SQL
Data adapters SQLSelectCommand, the SQLEditCommand, SQLInsertCommand etc. I
even got the base form code to modify the BindingContext so the update and
inserts worked flawlessly.

The base form has a dataset defined on it. I was HOPING to modify the code
for the dataset so that I could use the same Table Name and Key Name fields
to dynamically create the dataset like I was able to do with the
SqlDataAdapter's command strings. My real form inherits the base form,
initializes a base form instance and then sets my two protected strings in
the base form. Thusly:

Public Class frmIOClass
Inherits TheClassForm.frmTheClass

#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call
'*gs* These override the Protected strings in the base class
' of this form.

MyClass.strTheTable = "Input_Output_Class"
MyClass.strTheKey = "IOClass"
End Sub

Then in the load event of the baseform the code executes to generate the
SQLDataAdapter command strings. I tried putting code in the load event that
would populate some Protected strings in the dataset class code module. But
I soon realized that was WAY too late. The initialization code for the
dataset class was executed when the base form itself was initialized. It
was at that time that the dataset class was instantiated.

I'm stumped. I can't figure out how to get the Private strings set with the
Table Name and Key Name in the dataset class code BEFORE the dataset class
initialization code executes. I found the code in the base form that
actually instantiates the dataset. Here is a bit of that code:
Friend WithEvents dsTheClass As TheClassForm.dsTheClass
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

Dim resources As System.Resources.ResourceManager = New
System.Resources.ResourceManager(GetType(frmTheClass))
Me.txtTheClassName = New System.Windows.Forms.TextBox
Me.dsTheClass = New TheClassForm.dsTheClass
Me.txtTheClassDescription = New System.Windows.Forms.TextBox
Me.btnCancel = New System.Windows.Forms.Button
Me.btnOK = New System.Windows.Forms.Button
Me.SqlDataAdapter1 = New System.Data.SqlClient.SqlDataAdapter
Me.SqlDeleteCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlUpdateCommand1 = New System.Data.SqlClient.SqlCommand
CType(Me.dsTheClass, System.ComponentModel.ISupportInitialize).BeginInit()

I thought I could sneak in the code to set some private strings in the
dataset class right after the "Me.dsclass = New TheClassForm.dsClass" line
of code, but apparently VB wasn't kidding when I read the comment in the
code admonishing me as follows:

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.

Any code I try to add there gets "eaten" by the IDE. So I've hit the
proverbial brick wall. Anybody tried to tackle this before? Anyone have
any pearls of wisdom that they might share on this topic?

Thanks,

Gary Shell


 Reply:
by:One Handed Man \( OHM - Terry Burns \)

 If ever a wizard there was !, Wizards can help or hinder !

On the base form, take out all that code generated by the Visual Designer
and put it into a helper function. Delete the visual elements and do the
coding from scratch. Test your base form.

Arrange for this function to accept parameters you need to alter the
initialisation.

Now in your constructor for the subclass'ed form, call your helper function
to set up the appropriate table values etc

HTH
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing


 Reply:
by:Cor Ligthert

 Hi Gary,

I think that you can get what you want this when you are not using a typed
dataset as you do.
That typed dataset is set as class in your project.
You can see it when you set in the solution explorer to all files and push
on the +'s
That dataset class is generated from the XSD in design time and uses table
and datanames.
I think that it is therefore almost impossible to reach what you want.

However just my thougth.

Cor



Posted by Xander Zelders
0 Comments



Controls Layout

Found the following interesting discussion in the Newsgroups:

Controls Layout
by:Adriano

hello,

how to make a button to lay on the top of all controls in a form???

thx in advance,
Adriano


 Reply:
by:rawCoder

 Hi Adriano,

In the IDE , Right Click on the Button and select "Bring To Front"

Hope this helps.
rawCoder


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 

Place it on top of all controls?

Or are you referring to the Z-order? Then select the control and choose
'BringToFront' method at runtime).

--
Herfried K. Wagner



Posted by Xander Zelders
0 Comments



Form Switching

Found the following interesting discussion in the Newsgroups:

Form Switching
by:Stephen Keen

Ok I am a beginner, In VB prior to VB.Net I could create two forms and
switch between them very easily. Now I cannot seem to figure out how to do
it. Could someone show me how. This is not using mididocuments, but could
I guess. But why cant it stay simple?


 Reply:
by:tanuki

 i'm also learning this stuff but i found this
Dim MyNewForm as New Form2
myNewForm.Visible=True


 Reply:
by:Cor Ligthert

 
do
could

Probably because the behaviour in past could become very weird, however when
you start using them both in the same time you probably do not want them
both on screen, go with making them visible and hide them because that is in
fact what you than want. Than you can use by instance the visible change
event to reach your goals.

However there are so much ways to go now that this is only for this
situation.

When you want a dialogsituation where only the main form is active and you
sometimes want to use the dialog, than you can the best use the
dialogsituation.
dim frm as new form2
frm2.showdialog
myresult = frm.whateverfield
frm2.dispose

I hope this helps?

Cor


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 

<URL:http://www.google.de/groups?selm=er29781EDHA.584%40TK2MSFTNGP12.phx.gbl>

--
Herfried K. Wagner



Posted by Xander Zelders
0 Comments



RegisterWindowMessage return different in VB.NET and VC++

Found the following interesting discussion in the Newsgroups:

RegisterWindowMessage return different in VB.NET and VC++
by:lamngo@psv.com.vn (LamNgo)

Hi group,

I have two application that need to communicate with each other, one
written in C++ and the other in VB.NET. To communicate, I use
don't know why the RegisterMessage API return different value for the
same message string in C++ and VB.NET???
This is the code segment:

C++:
UINT nFoo = RegisterWindowMessage(_T("ExtraMessage"))

VB.NET:
Dim nBar As Int32
Private Declare Function RegisterWindowMessage Lib "user32" Alias

nBar = RegisterWindowMessage(_T("ExtraMessage"))

But the nBar is alway differ from nFoo!!!

Does anyone know the reason why?
I'm using VS.NET 2003, all apps is compile with unicode.

Thanks,


 Reply:
by:rawCoder

 Hi LamNgo

One thing that comes in mind is that the declaration should return long
instead on integer... somethign like this
Declare Function RegisterWindowMessage Lib "user32" Alias

Hope this helps
rawCoder


 Reply:
by:lamngo@psv.com.vn (LamNgo)

 Hi,

I follow your guide but the result is stranger. The value of
registered message is too large....and more different from the message
registered by VC++ app.....

Lam



 Reply:
by:Ken Tucker [MVP]

 Hi,

You are using the wrong version of RegisterWindowMessage meaning use
RegisterWindowMessageA not W. Second the Integer is the correct return
value. The vb6 long is the same as vb.net integer.

Private Declare Function RegisterWindowMessage Lib "user32" Alias
"RegisterWindowMessageA" (ByVal lpString As String) As Integer

Ken


 Reply:
by:Lam

 Thanks so much. I got it!!! Yeah!!!
Don't just participate in USENET...get rewarded for it!



Posted by Xander Zelders
0 Comments



Repeater and RS Server

Found the following interesting discussion in the Newsgroups:

Repeater and RS Server
by:tim

I'm trying to get my repeater access my ListChildren
method. Unfortunately i'm unable to insert into control.

here is my code.
aspx.vb
-------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
''Put user code to initialize the page here
Dim rs As New hcdco_appdev.ReportingService
rs.Credentials =
System.Net.CredentialCache.DefaultCredentials

' Return a list of catalog items in the report server db
Dim items As CatalogItem() = rs.ListChildren("/", True)

' For each report, display the path of the report

Dim ci As hcdco_appdev.CatalogItem
Dim reportValues As ArrayList = New ArrayList

For Each ci In items
If ci.Type = hcdco_appdev.ItemTypeEnum.Report Then
reportValues.Add(ci.Path)
reportValues.Add(New reportNames(ci.Path))
reportList.DataSource = reportValues
reportList.DataBind()

End If
Next ci
End Sub

business.Obj.vb
-------------------

Public Class reportNames


Private mReportName As String

ReadOnly Property ReportName() As String
Get
Return mReportName
End Get
End Property

Public Sub New(ByVal ReportName As String)
MyBase.New()
mReportName = ReportName

End Sub
End Class


 Reply:
by:One Handed Man \( OHM - Terry Burns \)

 Have you set up your templates and set up your data binding expressions ?,
if not do so, if so, what exactly is happening when you run the code ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing


 Reply:
by:tim

 all aspx code included my itemtemplate.

thanks but i figured it out. it was an extra line in my
aspx.vb code.

it was an extra reportvalues.add line.

thanks


 Reply:
by:One Handed Man \( OHM - Terry Burns \)

 Pleased to know that all was resolved.
Regards

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing



Posted by Xander Zelders
0 Comments



How to read newsgroup with Outlook Express?

Found the following interesting discussion in the Newsgroups:

reading newsgroup with Outlook Express
by:Anonymous

Hi can anyone access these newsgroups with Outlook Express anymore?


 Reply:
by:Ken Tucker [MVP]

 Hi,

Yes. The server name is msnews.microsoft.com

Ken


 Reply:
by:Ray

 thank you Ken, that's one major headache sorted


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 

.... or news.microsoft.com :-).

--
Herfried K. Wagner [MVP]



Posted by Xander Zelders
0 Comments



Use PictureBox.Image or DrawImage?

Found the following interesting discussion in the Newsgroups:

Use PictureBox.Image or DrawImage?
by: Just Me

I do the following where sss is a string equal to a filename.

PictureBox.Image = = New Bitmap(sss)

It occurred to me that the file will be locked until the picturebox is
disposed at the program end.

Would it make more sense to use DrawImage.

I mean, is that what programmers typically do?

Thanks


 Reply:
by:Ken Tucker [MVP]

 Hi,

If you open the bitmap with a filestream you won't lock the file.

Dim fs As New System.IO.FileStream("C:\camera.bmp",
IO.FileMode.Open)
Dim bm As New Bitmap(fs)

fs.Close()
PictureBox1.Image = bm
Ken


 Reply:
by: Just Me

 Perfect - thanks a lot



Posted by Xander Zelders
0 Comments



Word Automation replacement

Found the following interesting discussion in the Newsgroups:

Word Automation replacement
by:sergeb_@hotmail.com (SonOfMog)

Could someone make a recommendation for a third party software that do
things like Word automation?
In a batch mode, on a Win2000 server, we want to manipulate doc files
without using MS Word. In short, we want to merge some pre-written doc
files with another doc file and do some reformat.

I have read about Aspose products that seems fine.
Is there anything else?

Thanks,
Serge B.


 Reply:
by:Paul Bromley

 I would also be interested in recomendations. Note the OCX that I have
mentioned lower in the thread - useful for displaying Office document files.

Paul Bromley



Posted by Xander Zelders
0 Comments



Init classes in a Windows Service

Found the following interesting discussion in the Newsgroups:

Init classes in a Windows Service
by:Anonymous

I appear to be having problem with my Windows service because my classes are not getting init in my service. Please see code below:

Public Class AlertDataClass
' create Dataset and Tables
Public AlertDS As DataSet = New DataSet("AlertTables")
Public EventCriteriaTable As DataTable = AlertDS.Tables.Add("EventCriteria")
Public MinGPSHistoryTable As DataTable = AlertDS.Tables.Add("MinGPSHistory")
Public EventLogTable As DataTable = AlertDS.Tables.Add("EventLog")
Dim AlertVar As New AlertVariables

Sub AddDataColumnNames()

'Add Column Names for Criteria and Command Data

'Set Column Properties
Dim CriteriaColumnHeader As DataColumn = New DataColumn
CriteriaColumnHeader.DataType = System.Type.GetType("System.String")
CriteriaColumnHeader.AllowDBNull = False

' Add the Column Header to the table.
CriteriaColumnHeader.ColumnName = "CriteriaID"
EventCriteriaTable.Columns.Add(CriteriaColumnHeader)
CriteriaColumnHeader.ColumnName = "Min_Num"
EventCriteriaTable.Columns.Add(CriteriaColumnHeader)
CriteriaColumnHeader.ColumnName = "ReportingFrequenecy"
EventCriteriaTable.Columns.Add(CriteriaColumnHeader)
CriteriaColumnHeader.ColumnName = "TimeToLiveStartDate"
EventCriteriaTable.Columns.Add(CriteriaColumnHeader)
CriteriaColumnHeader.ColumnName = "TimeToLiveStartTime"
EventCriteriaTable.Columns.Add(CriteriaColumnHeader)
CriteriaColumnHeader.ColumnName = "TimeToLiveStopDate"
EventCriteriaTable.Columns.Add(CriteriaColumnHeader)
CriteriaColumnHeader.ColumnName = "TimeToLiveStopTime"
EventCriteriaTable.Columns.Add(CriteriaColumnHeader)

' Add Column Names for MinGPSHistory Data

' Set Column Properties
Dim MinGPSHistoryColumnHeader As DataColumn = New DataColumn
MinGPSHistoryColumnHeader.DataType = System.Type.GetType("System.String")
MinGPSHistoryColumnHeader.AllowDBNull = False

' Add the Column Header to the table.
MinGPSHistoryColumnHeader.ColumnName = "Hist_ID"
MinGPSHistoryTable.Columns.Add(MinGPSHistoryColumnHeader)
MinGPSHistoryColumnHeader.ColumnName = "Min_Num"
MinGPSHistoryTable.Columns.Add(MinGPSHistoryColumnHeader)
MinGPSHistoryColumnHeader.ColumnName = "LastGPSLNG"
MinGPSHistoryTable.Columns.Add(MinGPSHistoryColumnHeader)
MinGPSHistoryColumnHeader.ColumnName = "LastGPSLAT"
MinGPSHistoryTable.Columns.Add(MinGPSHistoryColumnHeader)
MinGPSHistoryColumnHeader.ColumnName = "LastTime"
MinGPSHistoryTable.Columns.Add(MinGPSHistoryColumnHeader)
MinGPSHistoryColumnHeader.ColumnName = "Speed"
MinGPSHistoryTable.Columns.Add(MinGPSHistoryColumnHeader)
MinGPSHistoryColumnHeader.ColumnName = "Direction"
MinGPSHistoryTable.Columns.Add(MinGPSHistoryColumnHeader)
MinGPSHistoryColumnHeader.ColumnName = "StatusBits"
MinGPSHistoryTable.Columns.Add(MinGPSHistoryColumnHeader)

' Add Column Names for EventLog

Dim EventLogColumnHeader As DataColumn = New DataColumn
EventLogColumnHeader.DataType = System.Type.GetType("System.String")
EventLogColumnHeader.AllowDBNull = False

' Add the Column Header to the table.

EventLogColumnHeader.ColumnName = "DateTimeofAlert"
EventLogTable.Columns.Add(MinGPSHistoryColumnHeader)
EventLogColumnHeader.ColumnName = "CriteriaID"
EventLogTable.Columns.Add(MinGPSHistoryColumnHeader)
EventLogColumnHeader.ColumnName = "Hist_ID"
EventLogTable.Columns.Add(MinGPSHistoryColumnHeader)
EventLogColumnHeader.ColumnName = "VehicleServiceID"
EventLogTable.Columns.Add(MinGPSHistoryColumnHeader)
EventLogColumnHeader.ColumnName = "OdometerID"
EventLogTable.Columns.Add(MinGPSHistoryColumnHeader)
EventLogColumnHeader.ColumnName = "ReadingID"
EventLogTable.Columns.Add(MinGPSHistoryColumnHeader)
EventLogColumnHeader.ColumnName = "ServiceID"
EventLogTable.Columns.Add(MinGPSHistoryColumnHeader)

End Sub

End Class
Public Class AlertVariables

Public Shared MinDevice As String
Public Shared CriteriaID As String

Dim MachineName As String = "XXXXXXX"
Dim DatabaseName As String = "XXXXXXXXXXXXX"
Dim UserID As String = "XXXXXX"
Dim Password As String = "XXXXXXXX"

Public AlertConnectionString As String = "Data Source=" & MachineName & "; User ID = " & UserID & "; Password = " & _
Password & ";Initial Catalog= " & DatabaseName

Public ToldToStop As Boolean = False ' Fales = Don't stop True = Stop
End Class

Sub StartAlertProcessing()

' InitEnvironment()

Dim AlertData As AlertDataClass
Dim AlertVar As AlertVariables
Dim Alerts = AlertData
Dim MessageProcessing As SageQuestMailer

AlertVar.ToldToStop = False 'Start Processing Alerts

AlertData.AddDataColumnNames()
Dim CurrentSystemDateTime As DateTime
Dim CurrentSystemDate As String
Dim CurrentSystemTime As String

Dim NoData As Boolean = True 'True no data is available, False Data is Available

Do Until AlertVar.ToldToStop = True ' We should stop processing when true

CurrentSystemDateTime = DateTime.Now
CurrentSystemDate = Left(CurrentSystemDateTime, 10)
CurrentSystemTime = Mid(CurrentSystemDateTime, 12, 10)
NoData = GetAlertCriteriaData(CurrentSystemDate, CurrentSystemTime)
If Not NoData Then
CreateAlerts()
WriteEventLogTable()
End If

Loop

End Sub

I get the followin error when I start my service:

Service cannot be started. System.NullReferenceException: Object reference not set to an instance of an object.
at AlertProcessor.AlertDataAccess.StartAlertProcessing() in C:\Documents and Settings\Louis\My Documents\Visual Studio Projects\AlertProcessor\AlertProcessor\AlertDataAccess.vb:line 31
at AlertProcessor.AlertProcesor.OnStart(String[] args) in C:\Documents and Settings\Louis\My Documents\Visual Studio Projects\AlertProcessor\AlertProcessor\AlertProcessor.vb:line 76
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)

Line 32 is in the "StartAlertProcessing" subroutine. The line reads as follows:

AlertVar.ToldToStop = False 'Start Processing Alerts

Why is this happing? What's wrong with my code? I've been working issue all day and I have not solution as of yet. Please help.


 Reply:
by:Dadox

 Object reference not set to an instance of an object

dim alertvar as alertvariables= new alertvariables()

Maybe...who knows.
news:E98E099C-74D8-4D8D-B224-D67D85C6BFE9@microsoft.com...
are not getting init in my service. Please see code below:
AlertDS.Tables.Add("EventCriteria")
AlertDS.Tables.Add("MinGPSHistory")
System.Type.GetType("System.String")
System.Type.GetType("System.String")
System.Type.GetType("System.String")
& "; User ID = " & UserID & "; Password = " & _
& DatabaseName
Stop
Data is Available
when true
CurrentSystemTime)
not set to an instance of an object.
C:\Documents and Settings\Louis\My Documents\Visual Studio
Projects\AlertProcessor\AlertProcessor\AlertDataAccess.vb:line 31
and Settings\Louis\My Documents\Visual Studio
Projects\AlertProcessor\AlertProcessor\AlertProcessor.vb:line 76
state)
follows:
all day and I have not solution as of yet. Please help.


 Reply:
by:Cor Ligthert

 Hi Dadox,

Why maybe?

dim alertvar as new alertvariables()

In my opinion your answer is correct.
(above how it can be done as well)

And than as well to overcome the next error

Dim AlertData As New AlertDataClass

Cor



Posted by Xander Zelders
0 Comments



Listbox Refresh problem

Found the following interesting discussion in the Newsgroups:

Listbox Refresh problem
by:Aaron Bellante

I am fairly new to VB so please be gentle. :)

I am teaching myself about web services and I have been messing around
with Amazon.coms services. I am able to run a search and populate a
listbox with the names of books returned from a search. However, if
another search is run the listbox does not show the new results, however
it HAS been repopulated with the new results. As I can select with the
mouse and certain Labels that show price and name change.

Here is the bit of code that popuklates the listbox:

With lstResults
.BeginUpdate()
.DataSource = Nothing
.Items.Clear()
.DataSource = allDetails
.DisplayMember = "ProductName"
.SelectedIndex = 0
.EndUpdate()
End With
Any help will be greatly appreciated.

--
Aaron Bellante

-I Do not suffer from insanity. I rather quite enjoy it.


 Reply:
by:Anonymous

 SelectedIndex can't be 0 because there is no item in Items collection. should be -1




Posted by Xander Zelders
0 Comments



Can't find a function in the framework. Help Please?

Found the following interesting discussion in the Newsgroups:

Can't find a function in the framework. Help Please?
by:Anonymous

I am writing a program that is using the sockets interface in vb.net. When I was doing research for the project I remember running across a function/method that was something like .networkbyteorder and .hostbyteorder; or maybe .getnetworkbyteorder, etc. I can't seem to turn up a reference now. Does this ring a bell for anyone? Thanks!

Dan


 Reply:
by:Imran Koradia

 NetworkToHostOrder and HostToNetworkOrder - is this what you were looking
for?
they're the members of the IPAddress class under the System.Net namespace.
hope this helps..

When I was doing research for the project I remember running across a
function/method that was something like .networkbyteorder and
..hostbyteorder; or maybe .getnetworkbyteorder, etc. I can't seem to turn up
a reference now. Does this ring a bell for anyone? Thanks!



Posted by Xander Zelders
0 Comments



Send/Listen Commands on LAN

Found the following interesting discussion in the Newsgroups:

Send/Listen Commands on LAN
by:B-Dog

Can someone point me in the right direction or tell me if it is possible to
do this? I'm new to VB but have a buddy that is really good but we can't
really find anything on doing this. We have built a small application that
we are running on the workstations at the office and we need to do global
updates to the local databases. We are using 98/2000 machines. We would
like to have app listening to certain port or something and be able to send
out a global update command to tell the app to perform a certain operations.
Is this possible. Please help. Thanks


 Reply:
by:Anonymous

 You could do this via a Remoting call to a Windows Service that did the updates.

HTH
--
David Williams


 Reply:
by:B-Dog

 Would this work on 98 machines? Can you point me to any website with
sample/help? Thanks!


 Reply:
by:David Williams , VB.NET MVP

 You can use remoting to talk FROM the 98 machine, no problem. I am not
sure that you can host a remoting session on one though - do not have
one to test on. I know that it would have to be a running program, not
a Windows Service however, as 98 does not support services. It could be
a background application (i.e. a console app) however that was started
from the Autoexec.BAT (whew, I have not thought about THAT in a while!)

HTH

David


 Reply:
by:Barclay Berger

 Hey thanks for the help, I think we found exactly what we needed. Got us
pointed in the right direction. Thanks



Posted by Xander Zelders
0 Comments



Book recommendation?

Found the following interesting discussion in the Newsgroups:

Book recommendation?
by:Terry

I come from a VB 6 background.
Can anyone recommend a good book for VB.NET and ASP.NET.

Terry


 Reply:
by:Anonymous

 The book is "Microsoft's Programing Visual Basic .NET" by Balena.

HTH
--
David Williams


 Reply:
by:Supra

 good book. but have petzold 's book too. also have many microsoft press
books. contained no bugged..
regards


 Reply:
by:Greg Burns

 ASP.NET Unleashed, Second Edition
by Stephen Walthe.



Posted by Xander Zelders
0 Comments



Set Row color in DataGrif Web From

Found the following interesting discussion in the Newsgroups:

Set Row color in DataGrif Web From
by:Anonymous

Public theDataSet As DataSet
Private Sub Page_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
DataGrid1.DataSource = theDataset ' populate Dataset from Call to Web Service
DataGrid1.DataBind()
End If
End Sub
Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As _ DataGridItemEventArgs) Handles DataGrid1.ItemCreated
If (e.Item.ItemIndex <> -1) Then
Dim strTest As String = theDataSet.Tables(0).Rows(e.Item.ItemIndex).Item(7)
If ((InStr(1, strTest, "NC") <> 0) Or InStr(1, strTest, "ICE") <> 0) Then
e.Item.BackColor = System.Drawing.Color.LightPink
End If
End If
End Sub


 Reply:
by:Cor Ligthert

 




Posted by Xander Zelders
0 Comments



Form not refreshing

Found the following interesting discussion in the Newsgroups:

Form not refreshing
by:Steve Hoyer

Good day.

I wrote an application to convert data from one database to another. It
runs through about 100,000 records for this conversion. That bit works
fine.

I have on the form a progress bar and a label to tell me how far it has
gotten and what record it is currently on, respectively.

The problem is that usually (but not always), as it is processing
records, the form stops refreshing and appears to hang. I am even told
by Task Manager that it is Not Responding. However, the hard drive is
churning, and if I leave it go for a while, it will eventually finish
processing.

This happens during debug as well. I can pause it in debug and see that
it is running (the counters continue incrementing). If I pause and step
through to just after my me.refresh (which happens at the end the
process of each record), it still doesn't actually refresh the form.

Thanks for any help.

Steve Hoyer
Don't just participate in USENET...get rewarded for it!


 Reply:
by:Ken Tucker [MVP]

 Hi,

Place Application.DoEvents in your loop. It will allow the form to
update itself.
Ken


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 

You could call 'Application.DoEvents' every n-th dataset you are
processing, or you could move the processing stuff into a separate
thread that updates the UI using invoke. A sample for thread-safe
updating an UI from another thread can be found here:

<URL:http://dotnet.mvps.org/dotnet/samples/filesystem/downloads/FileSystemEnumerator.zip>

--
Herfried K. Wagner [MVP]


 Reply:
by:Steve Hoyer

 I added the doevents so it runs every 100 records and it works great.
Thank you.

Steve Hoyer
Don't just participate in USENET...get rewarded for it!



Posted by Xander Zelders
0 Comments



Execute a program

Found the following interesting discussion in the Newsgroups:

Execute a program
by:Ronan

Hi everybody!!!
Does anybody knows how can I run a ".EXE" or ".VBS" program remotely in the
same or diferents domains using VB.net?

Thanks in advance!!!
Ronan


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 

'Shell' or 'System.Diagnostics.Process.Start'.

--
Herfried K. Wagner [MVP]


 Reply:
by:Ronan

 Cool!!!
Thanks Herfried!!!

Do you know how can I execute that process from one machine in another one?
For example:
I´m executing a ".exe" file in a machine A, and from the machine A I
call another ".exe" file in machine B.

Thanks again!!!
Ronan



Posted by Xander Zelders
0 Comments



How to make one of two child windows always on the top?

Found the following interesting discussion in the Newsgroups:

How to make one of two child windows always on the top?
by:barbara_dave@yahoo.com (barbara)

Hi, all

I want to display two child windows in the MDI window at the same time
and I use: Me.LayoutMdi(MdiLayout.TileHorizontal). But It switches
that two windows' positions sometimes. How can I make a particular one
always on the top and the other on the bottom?
Thanks!


 Reply:
by:Anonymous

 I think only way is to set MDIParent's ActiveForm property to the one you want on top



Posted by Xander Zelders
0 Comments



VB.NET Form Designer

Found the following interesting discussion in the Newsgroups:

VB.NET Form Designer
by:Anonymous

I have VB.NET project with multiple forms. I can view and work woth all forms in the project in normal design mode on one machine but not on another. Both instances of Visual Studion are accessing thr same source code; both are 2003 version.

The project executes OK on both systems and I can see the code for all forms on both machines. But on one machine I get an "object reference not set to an instance of an object" message when I attempt to see the form's design/layout.
--
Al S


 Reply:
by:Anonymous

 It sounds like you have a control on the form that is not on the second machine. Check your references and dependancies.

HTH

--
David Williams



Posted by Xander Zelders
0 Comments



Help with regular expression

Found the following interesting discussion in the Newsgroups:

Help with regular expression
by:dotNet

Hi!

I have this code, to replace www/http/mailto/ftp-links to a real <a
href>-tag.

----
Dim mDelimit As String = Chr(0)

oRegEx = New
Regex("[^<a](\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+)",
RegexOptions.IgnoreCase)
content = oRegEx.Replace(content, "<a href=""mailto" & mDelimit &

oRegEx = New Regex("[^<a](http://|https://|ftp://|mailto:)(\S)(\S+)",
RegexOptions.IgnoreCase)
content = oRegEx.Replace(content, "<a href=""$1$2" & mDelimit &

oRegEx = New Regex("[^<a](www\.(\S)(\S+))", RegexOptions.IgnoreCase)
content = oRegEx.Replace(content, "<a href=""http://$1"">$1</a>")

content = Replace(content, mDelimit, "")
----

But it doesnt work very well, any suggestions?

I also want to be able to write [url=http://www.myurl.com]my url
description[/url] and parse that to an a-tag aswell.
I have this code:

----
oRegEx = New Regex("\[url=(.*?)\](.*?)\[\/url\]")
content = oRegEx.Replace(content, "<a href=""$1""
target=""_blank"">$2</a>", RegexOptions.IgnoreCase)
----

The problem with the code above is that if I have code like this:

[url=http://test1.com]test1[/url]
[url=http://test1.com]test2[/url]

[url=http://test1.com]test3[/url]
the link test1 and test2 will be parsed ok, but the link test3 will stay
in plain text. I guess that is because we have a empty row above the text.
Thanks!


 Reply:
by:Du Dang

 Hi,

If all you want to do is convert a address into a html link then try this.
================================

Dim sample As String = "www.w3.org text http://w3.org w3.org w3.okey
text king.kong.ca"

' http://|https://|ftp://|mailto:
Dim link As String = Regex.Replace(sample,
href=""${link}"">${link}</a>")

' www <===== if u only want to get domains that starts
with www then use this
' link = Regex.Replace(link, "(?<link>(?<=(^)|(\s))www\S+)", "<a
href=""http://${link}"">${link}</a>")

' address doesn't start with http://|https://|ftp://|mailto:
link = Regex.Replace(link,
href=""http://${link}"">${link}</a>")

Console.WriteLine("Sample: {0}", sample)
Console.WriteLine("Link: {0}", link)

================================
NOTE: these regex doesn't validate any of the addresses
ie 30000.com or http://helloworld still consider a valid domain

btw what is the delimiter (mDelimit) do ?

hope that helps,

Du


 Reply:
by:Du Dang

 oops .. i think i messed up

just use the

' www <===== if u only want to get domains that starts
with www then use this
' link = Regex.Replace(link, "(?<link>(?<=(^)|(\s))www\S+)", "<a
href=""http://${link}"">${link}</a>")

instead of the other one :-(
Regard,

Du



Posted by Xander Zelders
0 Comments



How to populate a second drop down based on the content of a first?

Found the following interesting discussion in the Newsgroups:

How to populate a second drop down based on the content of a first
by:Anonymous


Hi,

I have two drop downs and the content of the second one must changed everytime the user changes the selection in the first one. Is any easy way of doing this?

Thanks in advance.
Alonso



 Reply:
by:One Handed Man \( OHM - Terry Burns \)

 Are these bound to tables in a dataset. If so, bind one to the master and
one to a DataRelation which you need to create between the master and
dependent table.

If this is not the case that they are bound, then what criteria are you
using to fill the Combo's

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies wh