Import Hi-Res Contacts - Windows Mobile Software Development

I wrote this utility to batch import hi-res contact photos (256x256 or whatever you want) to my contacts. The trick is to name the jpg files "firstname_lastname.jpg" so it will find a match.
I am not a programmer, so don't be too hard on me. I've learned a lot from xda-developers and just want to give a little back. Hope you like it.
contact_pictures.exe v1.0 (unzip and run it on your diamond, no cab, no install)
Source Code is shown below, NET CF on Visual Studio 2005 VB
' --- source code ---
' Joe Jones
' 6/16/10
Public Class Form1
Dim cnt As Integer
Dim AppSession As New Microsoft.WindowsMobile.PocketOutlook.OutlookSession
Dim myContacts As Microsoft.WindowsMobile.PocketOutlook.ContactCollection = AppSession.Contacts.Items
Dim session As Microsoft.WindowsMobile.PocketOutlook.OutlookSession = New Microsoft.WindowsMobile.PocketOutlook.OutlookSession()
Dim contacts As Microsoft.WindowsMobile.PocketOutlook.ContactCollection = session.Contacts.Items
Dim contact
Dim PathStr As String
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
cnt = 0
TextBox2.Text = Str(myContacts.Count)
TextBox4.Text = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
End Sub
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
' parse through contacts looking for file to update pictures
Dim FirstNm, LastNm As String
' set folder for pictures
PathStr = TextBox4.Text
While cnt < myContacts.Count
FirstNm = myContacts.Item(cnt).FirstName
LastNm = myContacts.Item(cnt).LastName
TextBox2.Text = Str(cnt)
TextBox3.Text = FirstNm
TextBox4.Text = LastNm
' check for matching contact info with picture filename "firstname_lastname.jpg"
If System.IO.File.Exists(PathStr + "/" + FirstNm + "_" + LastNm + ".jpg") Then
myContacts.Item(cnt).SetPicture(PathStr + "/" + FirstNm + "_" + LastNm + ".jpg")
End If
' increment counter
cnt = cnt + 1
End While
' end app
TextBox3.Text = ""
TextBox4.Text = "Done"
End Sub
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
Me.Close()
End Sub
End Class

jonzjos said:
I wrote this utility to batch import hi-res contact photos (256x256 or whatever you want) to my contacts. The trick is to name the jpg files "firstname_lastname.jpg" so it will find a match.
I am not a programmer, so don't be too hard on me. I've learned a lot from xda-developers and just want to give a little back. Hope you like it.
contact_pictures.exe v1.0 (unzip and run it on your diamond, no cab, no install)
Source Code is shown below, NET CF on Visual Studio 2005 VB
Click to expand...
Click to collapse
Great, I will test it out soon. Thanks.

Here is the source code as a project so anyone can make it better and recompile it.
Putting the exe and jpg files into the same folder is the easiest thing to do.

Related

Problems with WindowsMobile.DirectX TextureLoader.FromFile

I'm trying to develop a simple application to my Omnia 2 in DirectX in VB.NET, but i stuck, really hard. I want to load a simple texture from a file, but the TextureLoader.FromFile gave me an InvalidCallException error. I don't know what to do, because the code is working on the emulator, but throw this error on the phone. I googled it, a lot, but found nothing.
I hope someone can help me in this.
Here's some code fragment. Please someone help me.
Code:
Function InitializeGraphics() As Boolean
Dim Parameters As PresentParameters = New PresentParameters()
Parameters.Windowed = True
Parameters.SwapEffect = SwapEffect.Discard
DeviceForm = New Device(0, DeviceType.Default, Me, CreateFlags.None, Parameters)
Me.OnCreateDevice(DeviceForm, Nothing)
Return True
End Function
Private Sub OnCreateDevice(ByVal sender As Object, _
ByVal e As EventArgs)
Dim dev As Device = CType(sender, Device)
spriteTexture = TextureLoader.FromFile(dev, "\Storage card\Picture.png")
Using s As Surface = spriteTexture.GetSurfaceLevel(0)
Dim desc As SurfaceDescription = s.Description
textureSize = New Rectangle(0, 0, desc.Width, desc.Height)
End Using
sprite = New Sprite(DeviceForm)
End Sub
Here's some picture from the exceptions details.
Nevermind. I solved it.

[Q] Standard and Professional

Newbie here. Maybe someone can give me some direction. I am writing an app for both standard and professional. I have 2 projects in my solution. One is for standard the othe is for professional. I am not sure if this is the right way or not but what I want to do is when the app opens it checks to see what platform is running and then runs the correct project. Any help would be greatly appreciated.
It is possible to create a single project that is capable of running on both platforms but there is quite a bit of groundwork you will have to do first.
Firstly, the main differences.
Standard : No touch screen i.e. No Mouse events. All user input is via the keyboard, buttons, D-PAD and ENTER. No Open/Save dialogboxes, you have to present the files to the user yourself. Message dialogs appear full screen.
Professional : None of the above limitations.
The are a few pointers here:
http://msdn.microsoft.com/en-us/library/bb985500.aspx
The following code will detect the platform and set the variable 'SmartPhone' to 1 (true) if the version is 'Standard'
Code:
#define MAX_LOADSTRING 100
int SmartPhone;
TCHAR szReturn[MAX_LOADSTRING];
SystemParametersInfo(SPI_GETPLATFORMTYPE,MAX_LOADSTRING,szReturn,false);
SmartPhone=wcscmp(TEXT("SmartPhone"),szReturn)^1;
Your processing code may have code such as:
Code:
if(SmartPhone)
{
........ Standard Stuff.......
}
else
{
......... Professional Stuff........
}
Note also that code dealing with a WM_LBUTTONDOWN message will never be executed on a smartphone, as WinMo Standard never generates this message.
It may seem a pain, but you only have one executable to deliver for both platforms.
As an example, here's one I prepared earlier.
http://forum.xda-developers.com/showthread.php?t=509413
more info
I am coding with VB. What I was thinking was creating a class project and making that the startup project. Within the class the VB would check the platform and then run the correct project.
Should work:
To get the Platform type in .NET CF have a look at:
http://msdn.microsoft.com/en-us/library/ms229660(VS.90).aspx
It's also listed in the VS Help.
I am using VS2008 TS and cf3.5. I have tried several methods and still can't get any to work. I must be missing a reference or something. Here is some code I can't get to work.
If SystemSettings.Platform = WinCEPlatform.PocketPC Then
txtDeviceType.Text = "Windows Mobile Professional"
ElseIf SystemSettings.Platform = WinCEPlatform.Smartphone Then
txtDeviceType.Text = "Windows Mobile Standard"
Else
txtDeviceType.Text = "Not Windows Mobile"
End If
Also tried this.
Public Enumeration WinCEPlatform
Dim instance As WinCEPlatform
I also tried getversionex but couldn't get it to work either.
I only code .NET in C# but there is virtually no difference.
Try this: You will have to add the reference to Microsoft.WindowsCE.Forms;
Right click on References in the Solution Explorer, click on Add Reference, in the .NET Tab, pick it out of the list.
Code:
using System;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsCE.Forms;
namespace Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
WinCEPlatform Platform = new WinCEPlatform();
Platform = SystemSettings.Platform;
label1.Text = Platform.ToString();
}
}
}
Works a treat!
Let's let Red Gate's Reflector translate the IL into VB.
It also reveals that the compiler rips outs the middle variables and goes straight for :
Code:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
Me.label1.Text = SystemSettings.Platform.ToString
End Sub
I am getting an error on this InitializeComponent. Another question. Can I add a class project and use this code to point to the correct project?
Drop the InitialiseComponent function, that is only used used in C#
In VB in Form1 the only code you need is
Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = Microsoft.WindowsCE.Forms.SystemSettings.Platform.ToString
End Sub
End Class
This code works and puts "YES" in the box if run on a PPC
Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Microsoft.WindowsCE.Forms.SystemSettings.Platform = Microsoft.WindowsCE.Forms.WinCEPlatform.PocketPC Then
Label1.Text = "YES"
End If
End Sub
End Class
Ok. I got it to work with the following code. But I have another problem. My app is a very simple app. I want it to work on PPC2003 and smartphones. I have 2 different forms for standard and professional. Now the problem is that if I use .net compact framework 3.5 then the device has to have that installed. So if I want to the app to work on older devices it won't work without the .net compact framework. If I use .net compact framework 2.0 then I lose the ability to use the code to determine if its standard or professional. I was hoping there was a way to include the 3.5 CF into my app cab but I haven't seen it. I am currently using VS2008 whcih only allows you 2.0 CF and 3.5 CF. I was thinking about using VS2005 and use 1.0 CF so it would work on all Windows mobile devices. But then I would again lose the ability to use the code. Any ideas would be appreciated.
Shared Sub Main()
Dim Platform As New WinCEPlatform()
Platform = SystemSettings.Platform
If Platform = "1" Then
Application.Run(
New Pro())
ElseIf Platform = "2" Then
Application.Run(
New Standard())
End If
End Sub
Using VS2005 I started a new project and selected SmartDevice 1.0. Now I have some issues.
1. Trying to determine either standard or professional. I am trying to use the Pinvoke to do this. No luck so far. I get an error on ByVal nFolder As ceFolders.
2. The code I was using to play a .wav file no longer works.
Dim myplayer As New System.Media.SoundPlayer(New IO.MemoryStream(My.Resources.Dice))
myplayer.Play()
3. I had resource files for images and a wav file so my code to use these no longer work.
Me.PictureBox1.Image = My.Resources.red_die_1_th
1. I'll have a look at it. Watch this space.
2. The SoundPlayer object is only available from .net CF 3.5 onwards. To play sounds you my have to PInvoke PlaySound()
http://msdn.microsoft.com/en-us/library/ms229685(v=VS.80).aspx
3. Should work, but maybe there's a difference in the frameworks. Microsoft's catch-all is that not all methods, properties etc. are supported in all .NET or .NET CF. versions. You may end up doing it in two stages, create a bitmap image from the resource, then pass that to the picturebox.
The answer to 1 is below. This works in C# under VS2003 .NET CF 1.0 but it is only in C#, I do not have VB installed on this machine. You will have to reverse engineer it into VB yourself, not too difficult. The important code is the DLLImport definition, the SPI_GETPLATFORMTYPE definition, and the call of the function in Form1_Load().
On program start "PocketPC" appears in the label on screen.
Code:
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
namespace PInvTest
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.MainMenu mainMenu1;
[DllImport("coredll.dll", EntryPoint="SystemParametersInfo", SetLastError=true)]
private static extern int SystemParametersInfo(
int uiAction, int uiParam, string pvParam, int fWinIni);
private const int SPI_GETPLATFORMTYPE = 257;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
string Platform = new string(' ',20);
SystemParametersInfo(SPI_GETPLATFORMTYPE,Platform.Length,Platform,0);
label1.Text=Platform;
}
}
}

[.Net DLL] WMLocationInfo - Get your location via CellID/GPS the easy way!

[01/2/11] Update v2.1 - Downgraded .net to v2.0 - Should now work with VS2005!
[31/1/11] Update v2 - Now includes GPS Support!
[30/1/11] Update v1 - Initial Release - CellID Only!
I have created this DLL to allow developers to quickly and easily add support for locations. By using CellID and now GPS!
CellID: This way is done by getting looking at the Cell Towers your mobile is connected to.. and then by searching a database of Cell Locations you can work out an approximate location for your Device, Which is usually accurate within 50-100m!
GPS: I'm sure we all know what GPS is and how it works Instead of using the Cell Tower location to find your location, It takes the co-ordinates from the GPS to then query an online source to figure out your location, Which is as accurate as GPS can get! If you're outside and not blocked by many buildings it should be as accurate as <5m
To download see the attachments 'WMLocationInfo.rar' contains the DLL file only..
If you are unsure how to go about using this DLL, I have included a sample C# application with full source code, This will show you how to get location by both CellID and GPS
Please take note of the copyright info below, before downloading and using my DLL and/or Source Codes
Thanks,
-David!
Copyright © 2011 David Bell / DavidTiger All Rights Reserved.
All Source Code, Compiled exe and DLL files are the copyrighted works of David Bell/DavidTiger.
You may use/redistribute any included samples or files, but you MUST leave credits where due.
You may NOT include this DLL and/or use its function in any commercial products with an intend to make a profit without written permission first!
All compiled DLL/EXE which do not include a source code have been obfuscated
You also may NOT attempt to dissasemble or reverse engineer any compiled obfuscated distributables (exe/dll).
-Included Sample Project in post #1-
hi thanks for the dll file. this is my code in VB:
Code:
'Setup variables needed throughout the source
Dim lat As String, lon As String = ""
Dim street As String, town As String, county As String = ""
Dim cellid As String, lac As String, mcc As String, mnc As String = ""
Private Sub GetCellId()
'Retreive cell tower info from the DLL
Dim CellTowerInfo As WMCellInfo.CellIDInfo.RILCELLTOWERINFO = WMCellInfo.CellIDInfo.GetCellTowerInfo()
'Asign each variable with its cell data
cellid = CellTowerInfo.CellID.ToString()
lac = CellTowerInfo.LAC.ToString()
mcc = CellTowerInfo.MCC.ToString()
mnc = CellTowerInfo.MNC.ToString()
End Sub
Private Sub GetCoord()
'setup args with cellid data
Dim args As String() = {mcc, mnc, lac, cellid}
'call DLL to get coords and then split them.
Dim latlng As String() = WMCellInfo.CoordinateInfo.GetLatLng(args).Split("|"c)
'assign them to their variables.
lat = latlng(0).ToString()
lon = latlng(1).ToString()
End Sub
Private Sub GetLoc()
'Call DLL to find location, with lat, lon parameters.
WMCellInfo.LocationInfo.Getlocation(lat, lon)
'Assign them into their variables.
street = WMCellInfo.LocationInfo.locations(0)
town = WMCellInfo.LocationInfo.locations(1)
county = WMCellInfo.LocationInfo.locations(2)
End Sub
Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
GetCellId()
Label1.Text = lac & vbCrLf & mcc & vbCrLf & mnc
End Sub
when i click on Menu_Item3, the app hangs. is there an error in my code?
Have you added "Imports WMCellInfo" at the very top of the code??
also
Added reference to the DLL??
other than that the code looks fine..
I'm not a developer, but... I think I'll have to thank you for a future software that will use your dll
Thanks
Update!!
Now includes everything you need for getting your location via CellID AND GPS!!
GPS Has slightly more code to be able to use it in your project but it is necessary to use GPS
I have included a C# sample of using the DLL to get the location with CellID and GPS
I will also include a VB code sample in the next few days as soon as I have time to write it
You'll find all this in the 1st post as soon as I upload it
-David
Hi david, i tried your sample code on my TD2 WM6.5 and it works. But when i use my own code:
Code:
Imports WMLocationInfo
Imports System
Imports System.IO
Imports System.Net
Imports System.Windows.Forms
Imports System.Text
Public Class Form1
'Setup variables needed throughout the source
Dim cellid As String, lac As String, mcc As String, mnc As String = Nothing
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Application.Exit()
End Sub
Public Sub GetCellID()
'Retreive cell tower info from the DLL
Dim CellTowerInfo As WMLocationInfo.CellIDInfo.RILCELLTOWERINFO = WMLocationInfo.CellIDInfo.GetCellTowerInfo()
'Asign each variable with its cell data
cellid = CellTowerInfo.CellID.ToString()
lac = CellTowerInfo.LAC.ToString()
mcc = CellTowerInfo.MCC.ToString()
mnc = CellTowerInfo.MNC.ToString()
'Show the data on the form with labels or other controls...
Label1.Text = "CellID = " & cellid
Label2.Text = "LAC = " & lac
Label3.Text = "MCC = " & mcc
Label4.Text = "MNC = " & mnc
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
GetCellID()
End Sub
End Class
it just hangs.
I just tested your code, copied and pasted without editing, added reference to the DLL and it works great :/
See my attached images to add reference to the DLL correctly, if you haven't already
I also attached the VB project I made with your code..
Hi David, i think i found the culprit. i'm coding using DotNetv2.0 instead of 3.5
How do i integrate 3.5 to my Visual Studio 2005?
oldsap said:
Hi David, i think i found the culprit. i'm coding using DotNetv2.0 instead of 3.5
How do i integrate 3.5 to my Visual Studio 2005?
Click to expand...
Click to collapse
You cant im afraid. 3.5 is only available to VS2008 and above.
I'll try compiling the dll under v2.0 tomorrow as it does work I used the same code for my app in vs2005 before upgrading to 2008 with .net 3.5.
I think its because the dll is built under 3.5 their is not backward compatable but building it under v2.0 means it should work for both v2.0 and v3.5
I'll try it in the morning and post back if it works, then update the dll if it does
cheers,
-David
DavidTiger said:
You cant im afraid. 3.5 is only available to VS2008 and above.
I'll try compiling the dll under v2.0 tomorrow as it does work I used the same code for my app in vs2005 before upgrading to 2008 with .net 3.5.
I think its because the dll is built under 3.5 their is not backward compatable but building it under v2.0 means it should work for both v2.0 and v3.5
I'll try it in the morning and post back if it works, then update the dll if it does
cheers,
-David
Click to expand...
Click to collapse
wow. thank you for your effort and time David.
-Updated post #1 with the dll using .net2.0, Should now work with VS2005 -
how do i get this on my phone?
This is only a DLL(Dynamc Link Library) of code which you can use to build your own program, using .netv2.0 and above with Visual Studio 2005-2008..
You can test the app I posted in post #1... Just copy the exe and dll from the bin/release folder and run it on your device..
Other than that you will have to write your own program to make use of this
An example is my 'Facebook Location' app I've posted
god this all goes over a common man head. need a simple xap file to make all this happen.
Cant open the sample project in VS2005.
Looking good though.
Yea, now I've downgraded the DLL I'll rewrite the VB and C# sample projects with 2005 anyone who uses 2008 it will update the project itself.
Gives the most compatibility, and use for people
DavidTiger said:
Yea, now I've downgraded the DLL I'll rewrite the VB and C# sample projects with 2005 anyone who uses 2008 it will update the project itself.
Gives the most compatibility, and use for people
Click to expand...
Click to collapse
Thanks, I could probably work through a VS2005 C# project but a VB one would be just ideal.
Just donated, have a beer or two on me. Would say whisky but the Irish stuff is better. LOL We have the best distillery 10 miles down the road.
Thanks! Can't say I've had many Irish whiskeys Jameson is about the only one I've tried. Oh and I had a glass or two of one my dad had, uhm Paddy I think it was called... 80 proof one
Mostly Scotch lol
I'll post up the VB one first, should be <30 minutes
If you get a chance try some Bushmills, best whiskey around.

[Q][Solved] Masking combobox items with text [VB.Net CF]

So basically this is what i need:
say i have a combo box that has 2 items, 0 and 1. When i say combobox1.SelectedItem and the number 1 is selected, it is then used within the program.
But what i want to do is have a combobox that displays say, on and off, but when on is selected a 1 is passed to the program.
Been googling this on and off for 2 weeks or so and I'm not able to find the answer and i know it can be done.
Thoughts and suggestions, as ever, are appreciated.
Use the SelectedIndex property of the ComboBox. It will return as an integer, a zero based index of the item selected, or -1 if no item is selected.
In your ComboBox, if the first item is 'Off' and the second, 'On', then the SelectedIndex property will return 0 and 1 respectively.
P.S. SelectedItem returns whatever is in the selected entry of the ComboBox.
stephj said:
Use the SelectedIndex property of the ComboBox. It will return a zero based index of the item selected, or -1 if no item is selected.
In your ComboBox, if the first item is 'Off' and the second, 'On', then the SelectedIndex property will return 0 and 1 respectively.
P.S. SelectedItem returns whatever is in the selected entry of the ComboBox.
Click to expand...
Click to collapse
OK that sounds pretty easy. I'm surprised i didn't find that in my searchs. Now lets up the anty. In EXCT2 i have a combobox that has the following items.
Code:
0
512
1024
2048
5120
10240
20480
102400
-2
-1
These are values used by the exchange (sync) configuration OMA service provider to configure the truncation point of html email messages. 512 is 0.5KB and it moves up to 100KB. Then -2 is text but no pictures and -1 is for the entire message. So if i wanted to say 0.5KB as the item how do i tell the program to use the value 512?
Hmmmm...... Trickier, but not impossible.....
Try this.
The secret is to connect the ComboBox to a DataSource, and let it get its DisplayMember and ValueMember properties from there.
You have to write a class to load and present the values then load them into an ArrayList first.
You then point the DataSource property of the ComboBox at the ArrayList, and let it get on with it.
Code:
Imports System
Imports System.Windows.Forms
Imports System.Collections
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim TruncVals As New ArrayList()
TruncVals.Add(New TruncVal("None", 0))
TruncVals.Add(New TruncVal("0.5Kb", 512))
TruncVals.Add(New TruncVal("1Kb", 1024))
TruncVals.Add(New TruncVal("2Kb", 2048))
TruncVals.Add(New TruncVal("5Kb", 5120))
TruncVals.Add(New TruncVal("10Kb", 10240))
TruncVals.Add(New TruncVal("20Kb", 20480))
TruncVals.Add(New TruncVal("100Kb", 102400))
TruncVals.Add(New TruncVal("Text no pictures", -2))
TruncVals.Add(New TruncVal("Entire Message", -1))
ComboBox1.DataSource = TruncVals
ComboBox1.DisplayMember = "TruncStr"
ComboBox1.ValueMember = "TruncInt"
ComboBox1.SelectedIndex = -1
TextBox1.Text = ""
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.SelectedIndex <> -1 Then
TextBox1.Text = ComboBox1.SelectedValue.ToString()
End If
End Sub
End Class
Public Class TruncVal
Private MyTruncStr As String
Private MyTruncInt As Integer
Public Sub New(ByVal StrVal As String, ByVal IntVal As Integer)
Me.MyTruncStr = StrVal
Me.MyTruncInt = IntVal
End Sub
Public ReadOnly Property TruncStr() As String
Get
Return MyTruncStr
End Get
End Property
Public ReadOnly Property TruncInt() As Integer
Get
Return MyTruncInt
End Get
End Property
End Class

[Q] Determining if a Sub needs to be run based on the object that called it [VB.Net]

Ok i know the title is not very good but this is a hard one to describe so briefly.
Basically i have a bunch of sub procedures that look a lot like this
Code:
[SIZE=2][COLOR=#0000ff]
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FBButton_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FBButton.Click[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]On[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Error[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Resume[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FBUsrnme [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\HTC\HTCAccountManager"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"FaceBookUserName"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FBpass [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\HTC\HTCAccountManager"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"FaceBookPassword"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FBsecret [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\HTC\HTCAccountManager"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"FaceBookSecret"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FBUsrID [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\HTC\HTCAccountManager"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"FaceBookUserID"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FBsession [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\HTC\HTCAccountManager"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"FaceBookSession"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FBToken [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\HTC\HTCAccountManager"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"FaceBookToken"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FBAccount [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\HTC\HTCAccountManager"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"FaceBookAccount"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FBSavePass [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\HTC\HTCAccountManager"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"FaceBookSavePassword"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] DirPath [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = SaveLocForm.Label28.Text[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sw [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IO.StreamWriter = IO.File.CreateText(DirPath + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\facebook.reg"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'Format and then write the reg file to disk[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]sw.WriteLine(RegHead)[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"[HKEY_LOCAL_MACHINE\Software\HTC\HTCAccountManager]"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""FaceBookUserName""="""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + FBUsrnme.ToString + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""FaceBookPassword""="""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + FBpass.ToString + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""FaceBookSecret""="""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + FBsecret.ToString + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""FaceBookUserID""="""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + FBUsrID.ToString + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""FaceBookSession""="""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + FBsession.ToString + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""FaceBookToken""="""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + FBToken.ToString + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""FaceBookAccount""="""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + FBAccount.ToString + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""FaceBookSavePassword""="""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + FBSavePass.ToString + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.Flush()[/SIZE]
[SIZE=2]sw.Close()[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'Check that the file wrote successfully (this needs work becuase it will always report "operation successful" once the file has been written once[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] File.Exists(DirPath + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\facebook.reg"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] fsi [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FileSystemInfo = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FileInfo(DirPath + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\facebook.reg"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (DateAndTime.Now - fsi.LastWriteTime) < [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] TimeSpan(0, 0, 5) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]OpComplete()[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]OpFailed()[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[/COLOR][/SIZE]
Now the bit i'm interested in is the final part because i have another part of my program that calls all the sub procedures like this
Code:
[SIZE=2][COLOR=#0000ff]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MenuItem2_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MenuItem2.Click[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]On[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Error[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Resume[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]ExchangeForm.exchangeSet_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]Soundbcklght.Backlghtset_click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]Identities.BTIdent_click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]Identities.PhoneIdent_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]Soundbcklght.bak_vol_set_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]Soundbcklght.RingSet_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]GPSForm.AGPSButton_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]GPSForm.LocServ_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]GPSForm.QGPS_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]ClockAlarmForm.TimeAutoUp_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]WiFiForm.WifiButton_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]VPNForm.VPNButton_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]AudioManager.AudioPathBut_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]SocialNetworks.FBButton_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]SocialNetworks.TwitButton_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]AudioManager.AlbumIgnore_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]HotmailForm.HotmailBut_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]MessageBox.Show([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"All Operations have run. All succesful exports can be found in "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + SaveLocForm.Label28.Text)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[/COLOR][/SIZE]
As you can see what happens when MenuItem2 is clicked is it runs through all of the sub procedures and at the end of each procedure there is a check to see if the file it is supposed to write was done successfully and they each then create a mesage box saying if they were successful or not. Then, once MenuItem2 has completed it creates a message box saying that all operations have run and tells you where they have been saved. So when you click MenuItem2 it basically creates 18 messageboxes that either say "operation complete" or "operation failed" followed by MenuItem2's own message box
What i want to happen (well actually my testers want it) is when you run say FBButton_click on it's own it creates the opcomplete or opfailed message boxes but when it is run as part of MenuItem2 it skips that part of the code.
So, i've moved the file write check out of a test procedure and into a module. Added a global variable so now the procedure looks like this
Code:
[SIZE=2][COLOR=#0000ff]
[SIZE=2][COLOR=#0000ff]Public[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] FBButton_Click([/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] sender [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] System.Object, [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] e [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] System.EventArgs) [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] FBButton.Click[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]On[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Error[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Resume[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FBUsrnme [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\HTC\HTCAccountManager"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"FaceBookUserName"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FBpass [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\HTC\HTCAccountManager"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"FaceBookPassword"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FBsecret [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\HTC\HTCAccountManager"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"FaceBookSecret"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FBUsrID [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\HTC\HTCAccountManager"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"FaceBookUserID"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FBsession [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\HTC\HTCAccountManager"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"FaceBookSession"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FBToken [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\HTC\HTCAccountManager"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"FaceBookToken"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FBAccount [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\HTC\HTCAccountManager"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"FaceBookAccount"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FBSavePass [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\HTC\HTCAccountManager"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"FaceBookSavePassword"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] DirPath [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = SaveLocForm.Label28.Text[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sw [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IO.StreamWriter = IO.File.CreateText(DirPath + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\facebook.reg"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'Format and then write the reg file to disk[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]sw.WriteLine(RegHead)[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"[HKEY_LOCAL_MACHINE\Software\HTC\HTCAccountManager]"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""FaceBookUserName""="""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + FBUsrnme.ToString + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""FaceBookPassword""="""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + FBpass.ToString + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""FaceBookSecret""="""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + FBsecret.ToString + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""FaceBookUserID""="""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + FBUsrID.ToString + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""FaceBookSession""="""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + FBsession.ToString + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""FaceBookToken""="""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + FBToken.ToString + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""FaceBookAccount""="""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + FBAccount.ToString + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""FaceBookSavePassword""="""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + FBSavePass.ToString + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.Flush()[/SIZE]
[SIZE=2]sw.Close()[/SIZE]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'Check that the file wrote successfully (this needs work becuase it will always report "operation successful" once the file has been written once[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]ModGlobal.dirpath1 = sw.ToString[/SIZE]
[SIZE=2]ModGlobal.FileCheck()[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[/COLOR][/SIZE]
and the module looks like this
Code:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] dirpath1 [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FileCheck()[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] File.Exists(dirpath1) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] fsi [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FileSystemInfo = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FileInfo(dirpath1)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (DateAndTime.Now - fsi.LastWriteTime) < [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] TimeSpan(0, 0, 6) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]ModGlobal.OpComplete()[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]ModGlobal.OpFailed()[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[/COLOR][/SIZE]
And this is where i get stuck. I have no idea how to write a check in to the test sub procedure that asks where it was called from and is then able to determine whether or not to call the FileCheck sub.
If you have any ideas i would be most greatful and i'm also sorry for the long post but it is a pretty complicted question.
The 'sender' parameter of an event handler points back to the object that originally caused this event handler to be triggered.
Create one Subroutine to handle both click events.
Use the Name property of the GetType() method of "sender", to decide which object invoked the event handler.
eg.
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, MenuItem2.Click
If sender.GetType().Name = "Button" Then
Label1.Text = "Button pressed."
End If
If sender.GetType().Name = "MenuItem" Then
Label1.Text = "Menu Clicked."
End If
End Sub
End Class
If you're going to do this in a separate subroutine from the click events, then you will have to pass it 'sender' as an argument, for your subroutine to decide, which of the event handlers called it.
Note that the above only identifies the type of the object that invoked the handler. If you want to find out exactly which of several objects of the same type invoked the handler then you need to create a variable of that type, and set it to the value of sender to allow you to access its properties.
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, MenuItem2.Click
If sender.GetType().Name = "Button" Then
Dim Source As Button
Source = sender
Label1.Text = "Button [" + Source.Text + "] pressed."
End If
If sender.GetType().Name = "MenuItem" Then
Dim Source As MenuItem
Source = sender
Label1.Text = "MenuItem [" + Source.Text + "] pressed."
End If
End Sub
End Class
Results in :
Code:
"Button [Go] pressed."
or
"MenuItem [Menu Go] pressed."
Ok but what if "menuitem" is on a different form to "button"? I think i understand the concept you discuss in your post but i'm having trouble implementing it because (and this is a guess) Menuitem2 lives in form1 and FbButton has it's own form. If i try referencing menuitem2 in FbButton's handlers it kicks back an error that i can resolve. To give you an idea this is kinda what i'm trying to achieve.
Code:
[SIZE=2][COLOR=#0000ff]Public[SIZE=2][SIZE=2]Sub[/SIZE][/SIZE][SIZE=2] FBButton_Click([/SIZE][SIZE=2][SIZE=2]ByVal[/SIZE][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][SIZE=2]As[/SIZE][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][SIZE=2]ByVal[/SIZE][/SIZE][SIZE=2] e [/SIZE][SIZE=2][SIZE=2]As[/SIZE][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][SIZE=2]Handles[/SIZE][/SIZE][SIZE=2] FBButton.Click, form1.menuitem2.click[/SIZE][/COLOR]
[COLOR=#0000ff][SIZE=2][SIZE=2]On [/SIZE][/SIZE][SIZE=2][SIZE=2]Error GoTo errorhandler[/SIZE][/SIZE][/COLOR][/SIZE]
[SIZE=2]
[COLOR=#0000ff][COLOR=black]-- SNIP --[/COLOR]
[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'Check that the file wrote successfully (this needs work becuase it will always report "operation successful" once the file has been written once[/COLOR][/SIZE]
[/COLOR][/SIZE]
[SIZE=2][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] sender.GetType().Name = Form1.MenuItem2 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/SIZE]
[SIZE=2][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]GoTo[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] endsub[/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/SIZE]
[SIZE=2][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/SIZE]
[SIZE=2][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] File.Exists(dirpath1) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][/COLOR][/SIZE][/SIZE]
[SIZE=2][SIZE=2]FileOWForm.ShowDialog()[/SIZE][/SIZE]
[SIZE=2][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE][/COLOR][/SIZE][/SIZE]
[SIZE=2][SIZE=2]ModGlobal.FileCheck()[/SIZE][/SIZE]
[SIZE=2][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][/SIZE]
[SIZE=2][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000][COLOR=#0000ff]End[/COLOR][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]errorhandler:[/SIZE]
[SIZE=2]ModGlobal.OpFailed()[/SIZE]
[SIZE=2]endsub:[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE]
[/SIZE]
I know that's wrong but i'm not sure how to make it work. Oh and FileOWForm basically asks if you want to overwrite the existing file, just so you know.
In that case on Form2 pass it straight through to the receiving event on Form1
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form1.Button1_Click(sender, e)
End Sub
The attached project is an example.
stephj said:
In that case on Form2 pass it straight through to the receiving event on Form1
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form1.Button1_Click(sender, e)
End Sub
The attached project is an example.
Click to expand...
Click to collapse
Cool thanks. I'll have a look at this later coz it's beer o'clock shortly
so i tied up the code in my program a little and had a play with what you came up with and i got this:
Code:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sender.GetType.Name = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Button"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]ModGlobal.FileCheck()
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sender.GetType.Name = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"MenuItem"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][/COLOR][/SIZE]
I haven't tested it yet coz i have other stuff to do but i was wondering if you think i got the basic idea?
Thanks again for being so helpful, steph
It will work, but as long as you are aware of the following proviso, it should be fine.
The code is determining its action solely by the type of the object that triggered the event. You may have to bear this in mind if you want to add a load more functionality, later.
The usual use for this sort of thing, is if you have a bunch of similar objects but want to write just one event handler to process events from all of them - a group of similar buttons, say. By using the trick in the middle code window in post #5, you can find out exactly which button of the group was clicked to invoke the handler, and run whatever code is required for that button. It prevents having to write the code for every button/event, especially if they have a large amount of similar code/shared functionality.
Good Luck! stephj.
Well i did some testing and i can't make the code i posted work (why am i not surprised) and i'm not sure i understand your last post. I've read it 5 times and it just doesn't seem to make sense. Is it me being retarded or is there a few typos in it?
What I meant, in a nutshell was this.
Nine buttons, only one event handler.
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _
Button1.Click, _
Button2.Click, _
Button3.Click, _
Button4.Click, _
Button5.Click, _
Button6.Click, _
Button7.Click, _
Button8.Click, _
Button9.Click
Dim SendingButton As Button
SendingButton = sender
Label1.Text = "Button " + SendingButton.Text + " Pressed"
End Sub
End Class
I give up!
Right, well i tried the method you posted above and Visual studio won't let me do it because there is no matching WithEvents variable for the second handle (probably because it is on a different form) and the method i posted in post 6 generates a nullreference exception at the first line.
I really can't figure out what i'm doing wrong, it's starting to irritate me and i've lost my patience for it.
Fancy volunteering some more of that brain of yours, Steph?
GetType is a method not a property.
Code:
If sender.GetType().Name = "Button"Then
ModGlobal.FileCheck()
EndIf
If sender.GetType().Name = "MenuItem"Then
ExitSub
EndIf
The included example below works. Here's the code for the two forms. The only deliberate change is to declare Form1's Button2_Click() as Public, to enable Form2 to be able to call it.
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form2.Show()
End Sub
Public Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim SenderButton As Button
SenderButton = sender
Label1.Text = "Button : " + SenderButton.Text + " clicked"
End Sub
End Class
Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form1.Show()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form1.Button2_Click(sender, e)
End Sub
End Class
I got it. I only saw the first half of your post when i was checking my mail this morning so i made the chagnge to gettype() and that got the first part working (calling it from it's own button).
After then calling the code from a menuitem on a different form and getting a failure it was revealed i made a noobie error. When i was calling the buttons function i was defining the objects like so
Code:
[SIZE=2]
Soundbcklght.Backlghtset_Click([COLOR=blue]Nothing[/COLOR], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])
[/SIZE]
instead of like this
Code:
[SIZE=2]
Soundbcklght.Backlghtset_Click(MenuItem2, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])
[/SIZE]
Now everything works fine. Thank you very much for helping once again, steph. I really can't express how greateful i am.

Categories

Resources