VB silverlight for windows phone - vb.net

I am writing an application in VB for windows phone 7.5
but it has some bug
Imports System.IO
Imports System.IO.TextReader
Imports System.Xml
Imports System.Windows.RoutedEventArgs
Imports System.Windows.RoutedEvent
Imports System.ComponentModel
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Net
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Shapes
Imports Microsoft.Phone.Tasks
Imports System.Xml.Linq
Imports System.Net.NetworkInformation
Imports Microsoft.VisualBasic.CompilerService
Partial Public Class MainPage
Inherits PhoneApplicationPage
Public Sub New()
InitializeComponent()
End Sub
Private Sub MainPage_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
Final.Items.Clear()
If NetworkInterface.GetIsNetworkAvailable Then
Dim cl As New WebClient
AddHandler cl.DownloadStringCompleted, AddressOf cl_DownloadStringCompleted
cl.DownloadStringAsync(New Uri("http://web.com/xml.xml"))
Else
MessageBox.Show("check your internet connection")
End If
End Sub
Private Sub cl_DownloadStringCompleted(sender As Object, e As System.Net.DownloadStringCompletedEventArgs)
Dim doc = XDocument.Parse(e.Result)
Dim names = XDocument.Parse(e.Result)
Dim result_name = names.<Data>.<Entry>
For Each result In doc.<Data>.<Entry>.<tag>
Dim item As New ListBoxItem
item.Content = result.Value
AddHandler item.Tap, AddressOf ItemTap
Final.Items.Add(item)
Next
End Sub
Private Sub ItemTap(sender As Object, e As GestureEventArgs)
Dim lbi As New ListBoxItem
lbi = sender
Dim url As New Uri("/" & lbi.Content & ".xaml", UriKind.Relative)
Me.NavigationService.Navigate(url)
End Sub
End Class
it finds a bug at Dim url As New Uri("/" & lbi.Content & ".xaml", UriKind.Relative)
and it says on the report :
Requested operation is not available because the runtime library
function
'Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject'
is not defined.
NOTE :
when i am changing the ItemTap to this :
Private Sub ItemTap(ByRef sender As Object, e As GestureEventArgs)
this error is gone and appears another one :
Method 'Private Sub ItemTap(ByRef sender As Object, e As
System.Windows.Input.GestureEventArgs)' does not have a signature
compatible with delegate 'Delegate Sub EventHandler(Of
System.Windows.Input.GestureEventArgs)(sender As Object, e As
System.Windows.Input.GestureEventArgs)'.
at line : "AddHandler item.Tap, AddressOf ItemTap"
Any ideas why i have this one ??
thank you !

You're trying to combine two strings and an object and it can't do this.
I strongly suspect that lbi.Content (in the line that is erroring) is a TextBlock, so your code says "concatenate a string, a TextBlock and a string together".
I suspect that you want the text that is displayed in the TextBlock, so just cast it accordingly:
"/" & DirectCast(lbi.Content, TextBlock).Text & ".xaml"

Related

Convert the program interface to another language interface VB.NET

What is wrong with the code to convert the program interface to another language interface? In Visual Basic .NET (Visual Studio 2019)
Imports System.Globalization
Imports System.ComponentModel
Public Class Form1
Private Sub ArButton_Click(sender As Object, e As EventArgs) Handles ArButton.Click
Languages.changelanguge("ar")
End Sub
Private Sub EnButton_Click(sender As Object, e As EventArgs) Handles EnButton.Click
Languages.changelanguge("en")
End Sub
End Class
Public Module Languages
Public Sub changelanguge(ByVal languge As String)
For Each obj As Control In Form1.Controls
Dim lang As ComponentResourceManager = New ComponentResourceManager(GetType(Form1))
lang.ApplyResources(obj, obj.Name, New CultureInfo(languge))
Next
End Sub
End Module
What is happening when you run the code? I was implementing this recently and the below link assisted a lot.
https://learn.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo?view=netframework-4.8

Print a report without preview view and without preview browser view

How can I print a report without the preview, and taking the default local printer?
I try to put this code lines, but does´nt work:
Dim rep As New XtraReport1()
rep.DataSource = DataSet
rep.CreateDocument()
rep.Print()
Thank you
I solve my problem with this code:
Imports DevExpress.XtraReports.UI
Imports System.IO
Imports DevExpress.XtraPrinting
Imports System.Data
Imports System.Drawing
Partial Class TPV_Tickets
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim Report As New TicketTPV
' THIS IS TO TAKE THE DEFAULT LOCAL PRINT
Dim instance As New Printing.PrinterSettings
Dim DefaultPrinter As String = instance.PrinterName
' THIS IS TO PRINT THE REPORT
Report.PrinterName = DefaultPrinter
Report.CreateDocument()
Report.PrintingSystem.ShowMarginsWarning = False
Report.Print()
End Sub
End Class

"New": Too many arguments

I made a "custom" form as seen below. When I say:
Dim nSplash As New frmSplash(nBitmap)
It is telling me that there are "too many arguments for Public Sub New".
I do not see why it is mocking about it.
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Runtime.InteropServices
Imports System.Windows.Forms
Namespace AlphaWindow
Public Class frmSplash
Inherits Form
Public Sub New(ByRef uBitmap As Bitmap)
Me.Size = uBitmap.Size
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
APIHelp.ShowTopmost(Me)
Me.SelectBitmap(uBitmap)
End Sub
(...)
' Class to assist with Win32 API calls
Class APIHelp
Private Const SW_SHOWNOACTIVATE As Integer = 4
Private Const HWND_TOPMOST As Integer = -1
(...)
End Class
End Namespace
The problem is not the Namespace, but when a namespace is included, the form has to be called by "Namespace.Form" instead of just "Form".

Windows service setup project custom dialog - how do i get the variables?

Quick question about a windows service, I've added a setup project for my Windows service, and ive added a custom dialog to it, with 4 text fields, but my question is how to i get these informations/variables?
Ive also added an installer for the windows service also, and afterwards the setup project, with the custom dialog.
The informations is something like database connection strings, and so on - so just string values.
This is my code for the "project installer" . the installer item ive added for the windows serive if you wanted to see it.
Imports System
Imports System.ComponentModel
Imports System.Configuration.Install
Imports System.ServiceProcess
Imports System.Runtime.InteropServices
Public Class ProjectInstaller
Public Sub New()
MyBase.New()
'This call is required by the Component Designer.
InitializeComponent()
My.Settings.TestSetting = Context.Parameters.Item("PathValue")
#If DEBUG Then
Dim ServicesToRun As ServiceBase()
ServicesToRun = New ServiceBase() {New tdsCheckService()}
ServiceBase.Run(ServicesToRun)
#Else
Dim listener As New tdsCheckService()
listener.Start()
#End If
End Sub
Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
MyBase.Install(stateSaver)
Dim regsrv As New RegistrationServices
regsrv.RegisterAssembly(MyBase.GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase)
End Sub
Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary)
MyBase.Uninstall(savedState)
Dim regsrv As New RegistrationServices
regsrv.UnregisterAssembly(MyBase.GetType().Assembly)
End Sub
Private Sub ServiceProcessInstaller1_AfterInstall(sender As Object, e As InstallEventArgs) Handles ServiceProcessInstaller1.AfterInstall
End Sub
Private Sub ServiceInstaller1_AfterInstall(sender As Object, e As InstallEventArgs) Handles ServiceInstaller1.AfterInstall
End Sub
End Class
You should eb able to access them using the Context object.
'Get Protected Configuration Provider name from custom action parameter
Dim variableName As String = Context.Parameters.Item("dialogSettingName")
Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
MyBase.Install(stateSaver)

how can i use ActiveDirectory

I have an active Directory (window) on the server ..and i want to connect it with my web pages..
this is my vb code:
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Data
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.DirectoryServices ' cannot be found '
Imports System.Runtime.InteropServices
Imports System.Configuration
Imports System.Data.SqlClient
Partial Class Default3
Inherits System.Web.UI.Page
Public Function IsADUser(ByVal UserName As [String], ByVal Password As [String]) As [Boolean]
Dim entry As New DirectoryEntry()
entry.Username = UserName
entry.Password = Password
Dim searcher As New DirectorySearcher(entry)
searcher.Filter = "(objectclass=user)"
Dim Authentecated As [Boolean] = False
Try
searcher.FindOne()
Authentecated = True
Catch ex As COMException
Authentecated = False
End Try
Return (Authentecated)
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
End Class
The ASP.NET Membership supports Active Directory as well. Check it out:
http://msdn.microsoft.com/en-us/library/ms998360.aspx
To use Active Directory manually, you should add System.DirectoryServices.dll as a reference before.