I am compiling a VB 6 code which requires serial communication from ports. For performing serial communication, I need some software tool like SAX Commstudio Active X or MSComm.ocx. But the problem is I have downloaded Sax Commstudio Active X from the commstudio official website, but that was a trial version for 1 day only. then i tried to download the same software from
http://visualstudiogallery.msdn.microsoft.com/en-us/
But the link is unavailable.
Now I am really in a fix how to get any of the serial communication software which is compatiable with VB 6 code. It will be better if some one provide me the sax commstudio download link or nay serial communication software downalod link!
Regards
Asad
Adding the VB6 MSComm Control to your Toolbar
In the VB6 IDE, select menu item Project, then select Components. The Components dialog box will appear. On this dialog, in the Controls tab, check the box next to the item 'Microsoft Comm Control 6.0' and then click the OK button on the dialog. This will add the component to your toolbar.
It's been a while since I've used this control but maybe this article will help you get started:
Visual Basic: MSComm Control
If you Google mscomm you'll find many more articles.
add the mscomm control in the components tab : Project - Components - Microsoft Comm Control 6.0
then add the control to your form and use the following code to configure and open it :
with mscomm1
.settings = "9600,N,8,1"
.commport = 1
.portopen = true
end with 'mscomm1
to send something :
mscomm1.output = "output to send"
use the oncomm event to receive data :
private sub mscomm1_oncomm()
dim strinput as string
select case mscomm1.commevent
case comevreceive
strinput = mscomm1.input
processdata strinput 'process the data here
end select
end sub
(code is unchecked, just typed in, but i think it should work :))
Related
I am getting so mad at trying to find out a working example. YES, I am new to VB.Net. I was used with VB6, long way back. I just cannot get that thing to do what I want.
My project: I am totally tired of using Steam and other 3rd party apps that require pairing and very hard or long configurations to emulate an XBox controller from a non-Xinput controller. I baught a RegeMoudal Pro Controller and OF COURSE, Windows does NOT read any button entries and I need to use a third party app. The problem with the apps is that they require too much configuration. I just want to transfer the controller's input into a Windows detectable input, that's it.
So, since I cannot go in FASM to do such a complexe project without breaking my head everywhere, I chose to go with the easy way, old school. I spent 2 days just figuring out that I had to reference UWP and a bunch of other things. Now, I said to myself, if I only get AT LEAST the list of devices connected on Bluetooth, I'll be able to start somewhere but nope. No matter what I find, noone has any Visual Basic codes to use in a clean way asside from very complexe code I barely understand.
Can someone please help me AT LEAST find out HOW to list all devices on Bluetooth. I do not care if they are connected or not, I just want to list the devices.
Here is what I got. A simple form with 1 single button and 1 single Label. I know, this just has a bunch of errors.
Imports Windows.Devices.Bluetooth
Imports Windows.Devices.Enumeration
Public Class FrmMain
Private Sub BouGetdev_Click(sender As Object, e As EventArgs) Handles BouGetDev.Click
Dim odevices = New DevicePicker
Dim odev As DeviceInformation
Dim sdevices As String
sdevices = ""
LabRes.Text = "Searching devices..."
For Each odev In odevices
sdevices = sdevices & Chr(13) & odev.GetType.Name
Next
End Sub
End Class
I just cannot figure out how to make this simple task so a gentle help would be nice.
I got discouraged because Windows does NOT capture any input of my controller detected as a Bluetooth Pro Controller but a simple webpage does capture every single input so I am annoyed because I was waiting for this controller since a long time because the XBOX ONE controller had serious joystick issues and made me rage quit games because the joystick would give small taps backwards when releasing it so those Xbox controllers are now on my blacklist because even when Microsoft sent it back to me, it had the exact same issue so I got a refund.
Now, I want to create my own version of Pro Controller to Xbox Controller input app. And I am insisting, Visual Basic code, not C++ or C#. And this is for WINDOWS, not android or any other systems. And refering to Microsoft's website to help does not either help because they give no samples in Visual Basic and I just don't understand the language they are using to explain everything, I'm just a simple person, oh, and the samples that can be taken need to be downloaded as project. I just want a sample code available neatly and easily without downloading anything.
So, after fideling so much with VB and trying to search. I finally found out how to list Bluetooth devices in Visual Basic (VB.Net).
FIRST of all, you NEED 32Feet.Net. I ran into the NuGet problem. I have absolutely NO clue what that is. After searching, I found out that nuGet packages can simply be unzipped using 7zip or other similar app. So here are the steps you need to do to prepare Visual Basic aka VB.Net to work with Bluetooth devices.
Go to 32Feet.Net's GitHub page here: https://github.com/inthehand/32feet
Download the "InTheHand.Net.Bluetooth - Bluetooth Classic" nuget package
Unzip the "nupkg" file in a folder of your choice
Open VB.Net
Navigate in the menus to "Project\Add a project reference..."
Click on the "Browse" button at the bottom of the project reference window
Browse in your newly downloaded and unziped nuget package folder under this path "runtimes\win\lib\netcoreapp#.#" and select the DLL "InTheHand.Net.Bluetooth.dll"
NOW you will be able to use the bluetooth functions. Next, we need to import the functions so they can be available when you code so you need to put this line at the very beginning of your project:
Imports InTheHand.Net.Sockets
Now that this is done, you can list you bluetooth devices. I will explain how I did my sample window. I put 1 button, 1 label and 1 timer object. When changing a label following the mentionned solution above with "Application.DoEvents()" My label still did not change text. So I used an old VB6 trick with a timer. I simply disable a timer object and when clicking on the button, I enable this timer which performs the actions I want. 1 VERY and excessively IMPORTANT thing, once you have started your timer actions, immediately disable your timer before performing any tasks inside this timer or else your function will repeat at the speed of your timer ticks.
So this is my complete code which lists the names of the Bluetooth devices on y computer in Visual Basic (VB.Net).
Imports InTheHand.Net.Sockets
Public Class FrmMain
Private Sub BouGetdev_Click(sender As Object, e As EventArgs) Handles BouGetDev.Click
LabRes.Text = "Searching devices..."
TmrBTScan.Enabled = True
BouGetDev.Enabled = False
End Sub
Private Sub TmrBTScan_Tick(sender As Object, e As EventArgs) Handles TmrBTScan.Tick
Dim bt_client As BluetoothClient = New BluetoothClient()
Dim odevices As BluetoothDeviceInfo() = bt_client.DiscoverDevices().ToArray()
Dim odev As BluetoothDeviceInfo
Dim sdevices As String = ""
Dim schr = ""
TmrBTScan.Enabled = False
For Each odev In odevices
sdevices = sdevices & schr & odev.DeviceName
schr = Chr(10) & Chr(13)
Next
LabRes.Text = sdevices
BouGetDev.Enabled = True
End Sub
End Class
This should list the names of all the Bluetooth devices. At least, it worked on my end and I hope this can help others that are looking for very clear steps in what to download, what to install, what to get, where to navigate, which files and what lines to code. It really is hard to get full complete instructions so I hope this helps.
Thanks for those that helped me here. I had to do some deep search, but at least I can get started on my project now.
First please fix this bug
The button_Click Event runs on the UI thread.
LabRes.Text = "Searching devices..."
the user will not see this text until the method finnished.
add this
LabRes.Text = "Searching devices..."
application.doevents()
It allows the UI to update while running code.
To get bluetooth devices in range
Private Sub SurroundingSub()
Dim client As BluetoothClient = New BluetoothClient()
Dim items As List(Of String) = New List(Of String)()
Dim devices As BluetoothDeviceInfo() = client.DiscoverDevicesInRange()
For Each d As BluetoothDeviceInfo In devices
items.Add(d.DeviceName)
Next
End Sub
I'm trying to run some automation tests in my application but the UFT Hidden-mode notification tooltip is coming in front of the objects in the screen, preventing my tests to run.
I know I can un-check the option "Display hidden-mode notification tooltip" in Remote Agent Settings to fix this issue and it works fine on my machine after I do this, but these tests are executed in other machines, by other users in my company, and it would be a real effort to tell each and everyone of them to change this setting on their machine.
Is it a way to disable this checkbox programmaticaly instead?
EDIT:
Here is a little more detail on where this is affecting me:
I'm testing a Web application and in some of my test cases I need to download a file from this application. I do that by clicking on "Save As" in the context menu which is displayed on a notification bar at the bottom of the browser.
Following is the portion of code to perform such operation:
Dim brwBottom
Set brwBottom = Browser("brw_Bottom_Save_As")
If brwBottom.WinObject("wo_Notification").WinButton("wb_Selector").Exist Then
brwBottom.WinObject("wo_Notification").WinButton("wb_Selector").Click
brwBottom.WinMenu("wm_Selector").Select "Save As"
End If
This works fine on my machine because UFT notification is not being displayed, but in other machines where the UFT Notification is displayed, it overlaps the menu and my script is unable to select the "Save As" option. So, in case it is not possible to programmatically close this notification at runtime, is there any alternative solution to click on the "Save As" button, even with this notification overlapping it?
I managed to identify the UFT Notification tooltip and close it. With this, there is no more objects in front of the button I need to click and my script can be executed successfully.
Following is the code used. I'm not marking this as the acceptable answer yet because I am still waiting for my team to accept the solution, but this works.
Dim brwBottom
Set brwBottom = Browser("brw_Bottom_Save_As")
' To close UFT Notification Tooltip, if exists
If Window("regexpwndtitle:=NotificationWindow").Exist(2) Then
If InStr(Window("regexpwndtitle:=NotificationWindow").GetROProperty("nativeclass"),"UFTRemoteAgent") > 0 Then
Window("regexpwndtitle:=NotificationWindow").Close
End If
End If
If brwBottom.WinObject("wo_Notification").WinButton("wb_Selector").Exist Then
brwBottom.WinObject("wo_Notification").WinButton("wb_Selector").Click
brwBottom.WinMenu("wm_Selector").Select "Save As"
End If
Create UFT GUI test and include these three lines:
extern.Declare micLong, "WritePrivateProfileString", "kernel32.dll", "WritePrivateProfileString", micString, micString, micString, micString
extern.WritePrivateProfileString "RemoteAgent", "ShowBallon", "0", Environment("ProductDir") + "\bin\mic.ini"
systemutil.CloseProcessByName "UFTRemoteAgent.exe"
From ALM, run it on all your UFT machines.
Notes:
This will switch the flag that controls such tooltip to be off, so next time Remote Agent launches will read it and won't display the tooltip anymore.
The third line will kill UFT's remote agent for GUI testing which is in charge of the communication between UFT and ALM Client and this will cause an error in ALM's Automatic Runner (The RPC server is unavailable)... just ignore it. We need to kill it so it is re-launched next time we try to run a test from ALM (as mentioned above, new value for tooltip will be read)
EDIT:
I just found something interesting: this flag is actually saved in two locations:
mic.ini
RemoteAgentGUISettings.xml
but the one that actually makes the change effective is RemoteAgentGUISettings.xml (it seems they're switching from .ini files to .xml... which makes sense). In this case, the code will change a little, but the idea is the same:
filePath = CreateObject("WScript.Shell").ExpandEnvironmentStrings("%appdata%") + "\Hewlett-Packard\UFT\Persistence\Dialogs\RemoteAgentGUISettings.xml"
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.load filePath
Set nNode = xmlDoc.selectsinglenode ("//SettingsViewModel/IsShowBalloon")
nNode.text = "false"
strResult = xmldoc.save(filePath)
systemutil.CloseProcessByName "UFTRemoteAgent.exe"
This time I made sure it works ;)
I totally understand your pain because my projects also need to interact with IE download bar. Usually, I use SendKeys to handle download activity in different projects.
When download bar comes out, you can send ALT+N first to set focus on download bar, then send some tab keys to select on Save, and some Down Arrow key to select SaveAs.
In this way, you don't need to bother handle UFT notifications...
Sample SendKeys codes can be easily Googled.
Can you activate the desired browser with the following, and then try to do Save as
hwnd = Browser("title:=.*").GetROProperty("hwnd")
Window("hwnd:=" & hwnd).Activate
I have this simple vbscript, but windows gives me an error when I'm trying to run it. I've never worked with vbscript before and i tried to google, but could figure out why. I'm getting expected end of line error at line 1, character 16. Does anyone see anything?
Also, I'm coding this in notepad and running it by double clicking the file. Is there any other way i should do it?
Dim WithEvents Button As CommandButton
Private Sub Application_StartUp(Cancel As Boolean)
Set Button = CommandButtons.Add("Click me")
End SubPrivate Sub Button_Click()
Msgbox "Clicked", vbInformation
End Sub
Since it was mentioned that notepad is being used for this and looking at the code this certainly appears to be code to add a button to a Form Based application using VBScript in Visual Studio.
VBScript via notepad is not really good at being used for creating GUI dialog boxes and such. A sample code of what would work using Notepad is as such:
toRepeat = InputBox("What should I repeat?", "Echo", "Hello World")
MsgBox toRepeat
Whatever is typed in to the input box will be repeated in this example.
If Visual Studio is not available and there is an interest in building a form based application then it may be possible to create User Forms in VBA via Word or Excel. The following site gives a good tutorial for creating a User Form application in Excel: Excel VBA Userform - Easy Excel Macros
In case there is interest, I recently wrote in to my blog an explanation of the different flavors of VB that are available: VBA vs VBSCRIPT vs Visual Basic
Thanks,
Sean W.
I am using OSVERSIONINFO to check the OS in my vb6 application. But i am not able differentiate between windows 7 and windows server 2008 R2 because they have same version number,dwMajorVersion and dwMinorVersion. So how to differentiate between these. I think it can be done in vb.net using some other method. But how it can be done in vb6?
As Xearinox noted in the above comment, OSVERSIONINFOEX returns more information.
In particular, you can examine wProductType to determine whether VER_NT_WORKSTATION (0x0000001) is set or not. If it is, the machine is running a client OS, otherwise, server.
The chart in the remarks section of the OSVERSIONINFO MSDN entry even has a column which points out detecting the various OS's using that struct item.
Right Click On Tool Bar > Components And Add > Microsoft SysControl 6.0.
Double Click The SysInfo Button to Add on Form and use this code
Private Sub Form_Load()
Dim HancyRockz as string
HancyRockz = "OsVersion :- " & SysInfo1.OSVersion & " / Built " & SysInfo1.OSBuild
Text1.Text=HancyRockz
End Sub
I have an application written in VB.Net with Visual Studio 2005. The application allows the user to create and save project files. When I distribute the application, I include some demo project files, which I install in the common application data folder.
XP - C:\Documents and Settings\All Users\Application Data
Vista & 7 - C:\Program Data
I have discovered an unexpected behavior -- if any file in the common application data folder is removed, and the application is run from the start menu, then the install procedure will start and attempt to restore the missing file(s). If the MSI file no longer exists at its original location or has been changed, then the application will fail to run. I perceive that this is a "feature", but it is one I don't want. Can anyone tell me what is going on and how I can avoid it?
Some more details:
I created the setup package by using a Visual Studio deployment
project.
This behavior will not occur if I launch the EXE directly. I
expect, therefore, that the behavior has something to do with the
start menu shortcut. I've noticed that the shortcut isn't a normal
shortcut -- it doesn't have a "Target Location".
All advice is appreciated.
-TC
I have learned that this behavior involves something called "Install-on-Demand" (aka "Self Heal"). The unusual shortcuts created by the setup package are called "Advertised Shortcuts". Now that I have a name for the problem, it is easy to find information on how to fix it. Notably:
http://msdn.microsoft.com/en-us/library/aa368297.aspx
http://groups.google.com/group/microsoft.public.dotnet.distributed_apps/browse_thread/thread/401847045f104af3
http://blog.jtbworld.com/2007/11/enable-target-and-change-icon-of.html
Those pages contain a wealth of information. For the convenience of others who may stumble upon this post, I will summarize what they say:
Advertised shortcuts are special shortcuts which do some fancy things. Most notably, they reinstall damaged application before launching their target. There is some debate over whether they are good, evil, or harmless. In my opinion, they do something most users don't expect, and that makes them evil. Therefore, I'd like to disable them for my application.
Visual Studio setup projects automatically create MSI packages which generate advertised shortcuts by default. It is easy to override that default when installing the MSI package by using DISABLEADVTSHORTCUTS=1 as a command-line argument for Setup.exe. Also, with a utility like Orca, you can manually change the default by inserting DISABLEADVTSHORTCUTS=1 as a property of the MSI. However, if you want Visual Studio to automatically create MSI packages which don't create advertised shortcuts, that is harder. I did it this way:
First, I created a VBS file using the DisableAdvt code provided by Gary Chang in one of the links above (I've repeated that code below). Just create a text file, paste in the code. and save it as DisableAdvt.vbs.
Then, create a post-build event for your setup project. The exact syntax will depend on your file locations. Because my DisableAdvt.vbs is in a "Tools" subfolder of the solution folder, my post-build event looks like this:
"$(ProjectDir)..\Tools\DisableAdvt\DisableAdvt.vbs" "$(BuiltOuputPath)"
That's all I had to do. It works like a charm.
-TC
Some notes:
In Visual Studio 2005, Build events are accessed differently for setup projects than they are for other types of projects. Click on the project name in the solution explorer, then look for PostBuildEvent in the Properties pane.
Orca is a utility that can be used to manually insert the DISABLEADVTSHORTCUTS property into the MSI file. With my approach, Orca is not necessary. However, it is useful for verifying that the build event is making the expected change.
http://www.technipages.com/download-orca-msi-editor.html
In the build event, the misspelling "BuiltOuputPath" is intentional.
Here is Gary Chang's DisableAdvt.vbs code (note that I fixed a typo on line 21 -- Very important!):
Option Explicit
Const msiOpenDatabaseModeTransact = 1
Dim argNum, argCount:argCount = Wscript.Arguments.Count
Dim openMode : openMode = msiOpenDatabaseModeTransact
' Connect to Windows installer object
On Error Resume Next
Dim installer : Set installer = Nothing
Set installer = Wscript.CreateObject("WindowsInstaller.Installer") :
CheckError
' Open database
Dim databasePath:databasePath = Wscript.Arguments(0)
Dim database : Set database = installer.OpenDatabase(databasePath, openMode) : CheckError
' Process SQL statements
Dim query, view, record, message, rowData, columnCount, delim, column
query = "INSERT INTO Property(Property, Value) VALUES ('DISABLEADVTSHORTCUTS', '1')"
Set view = database.OpenView(query) : CheckError
view.Execute : CheckError
database.Commit
If Not IsEmpty(message) Then Wscript.Echo message
Wscript.Quit 0
Sub CheckError
Dim message, errRec
If Err = 0 Then Exit Sub
message = Err.Source & " " & Hex(Err) & ": " & Err.Description
If Not installer Is Nothing Then
Set errRec = installer.LastErrorRecord
If Not errRec Is Nothing Then message = message & vbLf & errRec.FormatText
End If
Fail message
End Sub
Sub Fail(message)
Wscript.Echo message
Wscript.Quit 2
End Sub