Opening & Closing forms correctly

What would be the correct method to create an instance of a form? Currently, I add this to my AddinGlobal class in my Class project-
[code]Public Shared fForm As Form [/code] Then, when I need the form to be shown, I use this in the ribbon button command (loaded into Inventor)
[code]AddinGlobal.fForm = New fMain AddinGlobal.fForm.Show()[/code] This creates a new instance of the form. I have done it this way so that fForm can be accessed by other functions.

In my Form Class, I have these members that are new instances of some UserControls I have created [code]Public Shared pgStructure As New pAssyStructure Private pgAssembly As New pAssembly Private pgBorders As New pAssembly Private pgFlatPatt As New pFlatPattern Private pgPart As New pPart Private pgPresentation As New pPresentation Private pgSetting As New pSettings Private pgFrontSheet As New pFront[/code] Problem:

When I load the form first time, it works fine and everything loads as it should. When I close the form and then open it again, I get an error[img]https://social.msdn.microsoft.com/Forums/getfile/1010862[/img]
So, what is the best method to load the form, allow it to be accessible and open every time?

Thanks

System.Web.Security.MembershipUser.ChangePasswordQuestionAndAnswer Is encrypting PasswordAnswer

I’ve been using the System.Web.Security.MembershipUser.ChangePasswordQuestionAndAnswer method for several years and all has been fine. Now today something strange started happening. When I pass in the 3 parameters (password, passwordQuestion and passwordAnswer), the passwordAnswer appears to be encrypted when I view it in the sql aspnet_Membership table. For example, if I run this line of code:

user.ChangePasswordQuestionAndAnswer(“myPassword”, “myPet”, “dog”);

These are the values stored in the aspnet_Membership table:
Password = “myPassword”
PasswordQuestion = “myPet”
PasswordAnswer = “n51Do4TY8pYTAzyenYDe9d46Kjyc8oEbYbf4CRMzlE8=”

But I’m expecting PasswordAnswer to be “dog”.
Can anyone shed some light on what might be happening here?

everytime I used this in the past, PasswordAndwer would be "dog" in the aspnet_Membership table.

Additionaly, in the web.config file the SqlProvider passwordFormat attribute has always been set to "Encrypted" so this has not changed. Something else must have changed to cuase the PasswordAnswer to start encrypting.

Thank you.

Access/Download File OneDrive using vb.Net, is it possible..?

Dear Friends,

I have one file (Plain text File) in Microsoft OneDrive Public Folder,

I want to download or Access that file using VB.NET 2012.

Is there any way, Please

Thanks

Decrypt XML file error: Padding is invalid and cannot be removed

I encrypt an XML file and save it to the original file.
I then open the file and try to decrypt it, and get the error "Padding is invalid and cannot be removed".
I think this is because during encryption, I execute [code]key = New RijndaelManaged()[/code] And, during decryption, I also execute [code]key = New RijndaelManaged()[/code] How can I save the key from the encryption ?
Thank you.

This is the code to encrypt and save the XML file: [code]Imports System.Xml Imports System.Security.Cryptography Imports System.Security.Cryptography.Xml Dim key As RijndaelManaged = Nothing ' Create a new Rijndael key. key = New RijndaelManaged() ' Load an XML document. Dim xmlDoc As New XmlDocument() xmlDoc.PreserveWhitespace = True xmlDoc.Load("myXMLFile.XML") Encrypt(xmlDoc, "myElement1", key) Encrypt(xmlDoc, "myElement2", key) xmlDoc.Save("myXMLFile.XML")[/code] This is the code to decrypt the XML file: [code]Imports System.Xml Imports System.Security.Cryptography Imports System.Security.Cryptography.Xml Dim key As RijndaelManaged = Nothing key = New RijndaelManaged() Dim xmlDoc As New XmlDocument() xmlDoc.PreserveWhitespace = True xmlDoc.Load("myXMLFile.XML") Decrypt(xmlDoc, key)[/code]

how to insert data to database from datagridview?

I have some list of data in datagridview. More than 500 records in datagridview. i want to insert into database like this

for i =1 to 40

insert query 1.....

next

for i = 41 to 80

insert query 2.....

next

for i = 81 to 120
insert query 1.....

next

for i = 121 to 160
insert query 2.....

next

how to write a code in vb.net?

Android project, expanding preprocessor definition results in "error : stray '\' in program"

Hi !

I'm trying to compile two projects - I have made it so that one project is for Windows, another is for Android.

But basically same files are being compiled.

As a toolset I'm using gcc 4.9 for Android project.

In both project I have added extra define:

MODULE_STRING="core"

and windows project compiles fine, but in Android project I'm getting error:

1>..\src\audio_output\common.c(222,5): error : stray '\' in program
1> msg_Dbg( obj, "%s '%4.4s' %d Hz %s frame=%d samples/%d bytes", psz_text,
After expanding macro define I've realized that Microsoft C++ compiler pocesses "core" as a string, but in gcc

it result in following command line to gcc:

.. -D "MODULE_STRING=\\"core\\"" -x c++ ...

which results in \core\ macro expansion instead of "core" like in Microsoft compiler.

New bug ?

Trapping Key presses in C# Child form

I have seen several posts about trapping keys presses but none specific to child forms. In the code fragments below Key presses are trapped when the focus is the parent form but not when the focus is the child form. What else do I need to do to trap those also? I would also like to be able to trap arrow keys in the child form if possible. Unrelated code deleted. [code]public partial class Main : Form { private void btGraph_Click(object sender, EventArgs e) { Graph WaveGraph = new Graph("Waveform"); other code placing graphics on the form } // need to trap arrow keys. protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == Keys.Up) { MessageBox.Show("Up key pressed"); return true; } return base.ProcessCmdKey(ref msg, keyData); } } class Graph { public Graph(string name) { GraphForm = new Form(); GraphForm.Name = name; GraphForm.KeyPress += new KeyPressEventHandler(OnKeyPress); GraphForm.KeyPreview = true; } // The message box never appears private void OnKeyPress(object sender, KeyPressEventArgs e) { string KeyString = e.KeyChar.ToString(); MessageBox.Show("A key was pressed"); return; } }[/code]

Newing a derived class to create a default object

I have a base class which has several derived classes. Within the derived class I have an enum which tells me which derived class the object belongs to. Now, I want a function create a new object of a derived class, and the only parameter I'd pass would be the enum value of the class I want to create.

I can easily make a function which does a case/switch on the enum and does the appropriate new, but I was wondering if there is a better/more elegant/different way of doing it...?

Getting compilation errors after upgraded a C++ project from VS2013 to VS2017 RC

I converted a midsize C++ project (little less than 2 million lines of code) from VS2013 to VS2017 RC. The conversion went successfully, but when I attempted to compile, I got the following errors:
[code]1>------ Build started: Project: abcd, Configuration: Debug Win32 ------ 1>StdAfx.cpp 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\type_traits(1534): error C2760: syntax error: expected ')' not ',' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\type_traits(1825): error C2760: syntax error: expected ')' not ',' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\type_traits(1834): note: see reference to class template instantiation 'std::reference_wrapper<_Ty>' being compiled 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\type_traits(1944): error C2760: syntax error: expected ')' not ',' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xmemory0(528): error C2760: syntax error: expected ')' not ',' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xmemory0(563): error C2760: syntax error: expected ')' not ',' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xmemory0(641): error C2760: syntax error: expected ')' not 'identifier' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3623): warning C4467: usage of ATL attributes is deprecated 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\stdexcept(22): note: see reference to class template instantiation 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' being compiled 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3623): error C2337: '[': attribute not found 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3623): error C2146: syntax error: missing ']' before identifier 'noreturn' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3623): error C2143: syntax error: missing ';' before ']' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3623): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3624): error C2334: unexpected token(s) preceding '{'; skipping apparent function body 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3644): error C2337: '[': attribute not found 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3644): error C2146: syntax error: missing ']' before identifier 'noreturn' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3644): error C2143: syntax error: missing ';' before ']' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3644): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3645): error C2334: unexpected token(s) preceding '{'; skipping apparent function body 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\functional(34): error C2760: syntax error: expected ')' not ',' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\functional(38): note: see reference to class template instantiation 'std::_Mem_fn<_Memptr>' being compiled 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\functional(763): error C2760: syntax error: expected ')' not ',' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\functional(769): note: see reference to class template instantiation 'std::_Select_fixer<_Cv_TiD,false,true,0>' being compiled 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\functional(798): error C2760: syntax error: expected ')' not ',' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\functional(813): error C2760: syntax error: expected ')' not ',' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\functional(871): error C2760: syntax error: expected ')' not ',' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\functional(873): note: see reference to class template instantiation 'std::_Binder<_Ret,_Fx,_Types...>' being compiled 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\vector(1960): error C2146: syntax error: missing ']' before identifier 'noreturn' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\vector(1960): error C2143: syntax error: missing ';' before ']' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\vector(1960): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\vector(1961): error C2334: unexpected token(s) preceding '{'; skipping apparent function body 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\vector(1965): error C2337: '[': attribute not found 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\vector(1965): error C2146: syntax error: missing ']' before identifier 'noreturn' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\vector(1965): error C2143: syntax error: missing ';' before ']' 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\vector(1965): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\vector(1966): error C2334: unexpected token(s) preceding '{'; skipping apparent function body 1>Done building project "abcd.vcxproj" -- FAILED.[/code] Could you recommend how to find the reason of the errors?

The hard part is that all errors are in VS header files. I have not been able to turn more verbose output to get more details.

Thank you!

How to save data from checkedlistbox to access database?

Hello. I'm having trouble with inserting data to a database based on items checked on a checkedlistbox. There are two and the data on the checkedlistboxes are also from the same database but from different tables and they will serve as foreign keys to the table where I need to save them. I need it so that when the user finishes selecting the items and click the button, it would instantly save it to the database. Here is the code that I use to get the data from the database for both checkedlistboxes:
[code]Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load Using connection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\rose&mike\Desktop\DbSysDel3\salondbaccess.accdb"), adapter As New OleDbDataAdapter("SELECT Service_Name, Service_Fee FROM [Service_Types]", connection) Dim sql As String = "Select Lastname FROM Employees2" Dim cmd As New OleDbCommand cmd = New OleDb.OleDbCommand(sql, connection) connection.Open() Dim dr As OleDbDataReader = cmd.ExecuteReader If dr.HasRows Then While dr.Read chcklstbx2.Items.Add(dr(0)) End While End If Dim table As New DataTable adapter.Fill(table) With chcklstbx1 .DataSource = table .DisplayMember = "Service_Name" .ValueMember = "Service_Fee" End With connection.Close() End Using End Sub[/code]
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir