Help with visual basic - Off-topic

can some one help me find the errors on this program
Public Class DemoUpper
Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
Const strLowerCase As String = "visual basic"
strLowerCase = strLowerCase.ToUpper
txtOutput.Text = strLowerCase
End Sub
End Class

Try using the CODE tags around the text so it gets formatted correctly. Or paste it here and post the link http://pastebin.com/

veeman said:
Try using the CODE tags around the text so it gets formatted correctly. Or paste it here and post the link http://pastebin.com/
Click to expand...
Click to collapse
http://pastebin.com/0Qw1kKJ0#
Code:
Public Class DemoUpper
Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
Const strLowerCase As String = "visual basic"
strLowerCase = strLowerCase.ToUpper
txtOutput.Text = strLowerCase
End Sub
End Class

fujirio said:
http://pastebin.com/0Qw1kKJ0#
Code:
Public Class DemoUpper
Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
Const strLowerCase As String = "visual basic"
strLowerCase = strLowerCase.ToUpper
txtOutput.Text = strLowerCase
End Sub
End Class
Click to expand...
Click to collapse
You've declared "strLowerCase" as constant, so you can't assign a value to it, you can only read it. So, the working code should look like this:
Code:
Public Class DemoUpper
Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
Dim strLowerCase1 as string
Const strLowerCase As String = "visual basic"
strLowerCase1 = strLowerCase.ToUpper
txtOutput.Text = strLowerCase1
End Sub
End Class
But also you can make it shorter like this:
Code:
Public Class DemoUpper
Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
Const strLowerCase As String = "visual basic"
txtOutput.Text = strLowerCase.ToUpper
End Sub
End Class

kibermaster said:
You've declared "strLowerCase" as constant, so you can't assign a value to it, you can only read it. So, the working code should look like this:
Code:
Public Class DemoUpper
Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
Dim strLowerCase1 as string
Const strLowerCase As String = "visual basic"
strLowerCase1 = strLowerCase.ToUpper
txtOutput.Text = strLowerCase1
End Sub
End Class
But also you can make it shorter like this:
Code:
Public Class DemoUpper
Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
Const strLowerCase As String = "visual basic"
txtOutput.Text = strLowerCase.ToUpper
End Sub
End Class
Click to expand...
Click to collapse
wow thank you so much

Related

Waking the TyTN in C# ???

I'm wondering if anyone can give any pointers...
I'm trying to wake my TyTN from it's slumber in c#... after a few hours research I found an example in the MSDN that will set my "Beep" program to run at a certain time buy using CeRunAppAtTime. The problem is that although it works ... if the phones sleeping the screen doesn't activate ... (cont below)
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using HowDoI.Examples;
namespace DemoRunAppAtTimeCS
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void menuTest_Click(object sender, EventArgs e)
{
DateTime startTime = DateTime.Now + new TimeSpan(0, 0, 30);
long fileStartTime = startTime.ToFileTime();
long localFileStartTime = 0;
Win32.FileTimeToLocalFileTime(ref fileStartTime, ref localFileStartTime);
SystemTime systemStartTime = new SystemTime();
Win32.FileTimeToSystemTime(ref localFileStartTime, systemStartTime);
Win32.CeRunAppAtTime(@"\Windows\Beep.exe", systemStartTime);
}
}
}
Not a problem ... I know the programs activating so I thought if I mess about with the BKL1: and set it to "on" using DevicePowerState my test app will activate and the screen and speaker will then kick into life.
The problem is that it activates ... the screen comes on and then starts flashing or locks on so you can't turn it off without a reset. The speaker doesn't activate at all..... Can anyone shed anylight?? I'm not bothered about the screen but would love the speaker to activate to I can play a alarm.
Cheers
Phil
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace DeviceApplication8
{
public partial class Form1 : Form
{
public Int32 sd;
public Form1()
{
InitializeComponent();
SetDevicePower("BKL1:", POWER_NAME, DevicePowerState.D1);
sd = 0;
}
private void timer1_Tick(object sender, EventArgs e)
{
sd = sd + 1;
textBox1.Text = sd.ToString();
Microsoft.VisualBasic.Interaction.Beep();
}
public enum DevicePowerState : int
{
Unspecified = -1,
D0 = 0, // Full On: full power, full functionality
D1, // Low Power On: fully functional at low power/performance
D2, // Standby: partially powered with automatic wake
D3, // Sleep: partially powered with device initiated wake
D4, // Off: unpowered
}
private const int POWER_NAME = 0x00000001;
[DllImport("coredll")]
private static extern int SetDevicePower(
string pvDevice,
int dwDeviceFlags,
DevicePowerState DeviceState);
}
}
It's late so I can't be arsed trying this, but it looks like you haven't PInvoked the API call properly...
Try this
Code:
[DllImport("coredll.dll", SetLastError = true)]
static extern int SetSystemPowerState(string psState, int StateFlags, int Options);
const int POWER_STATE_ON = 0x00010000;
const int POWER_STATE_OFF = 0x00020000;
const int POWER_STATE_SUSPEND = 0x00200000;
const int POWER_FORCE = 4096;
const int POWER_STATE_RESET = 0x00800000;
#endregion
internal static void PowerOn()
{
SetSystemPowerState(null, POWER_STATE_ON, POWER_FORCE);
}
P.S. Check PInvoke.net and MSDN On SetSystemPowerState for more info.
Ta
Dave
Cheers Dave,
I'll give it a try tomorrow ... got a bottle of plonk in me and busy cooking a fish finger sandwich!!
Cheers
Phil
You're a star Dave ... ... changed my test program as per your advice and it works a treat!!! It wakes up even when locked, screen active, speaker active.
Thanks again for your help Dave ... I spent 10 hours on it yesterday with no joy!! Below's the code so maybe it'll help someone else.
Cheers
Phil
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace DeviceApplication8
{
public partial class Form1 : Form
{
public Int32 sd;
public Form1()
{
InitializeComponent();
SetSystemPowerState(null, POWER_STATE_ON, POWER_FORCE);
sd = 0;
}
private void timer1_Tick(object sender, EventArgs e)
{
sd = sd + 1;
textBox1.Text = sd.ToString();
Microsoft.VisualBasic.Interaction.Beep();
}
[DllImport("coredll.dll", SetLastError = true)]
static extern int SetSystemPowerState(string psState, int StateFlags, int Options);
const int POWER_STATE_ON = 0x00010000;
const int POWER_STATE_OFF = 0x00020000;
const int POWER_STATE_SUSPEND = 0x00200000;
const int POWER_FORCE = 4096;
const int POWER_STATE_RESET = 0x00800000;
}
}
If anyone every wonders how ... if you've set an application to run at a certain time, you can cancel the request by setting the run date/time to null
Win32.CeRunAppAtTime(@"\Windows\Beep.exe", null);
Cheers
Phil

Editing the Sense 2.1 quick setting menu

Hi guys,
Would we be able to alter the Quick Setting menu in Sense 2.1 and create an extra setting for Auto Rotate?
I'm sure it would be possible.
If anyone has some idea on how to do it, please reply.
I'm not very experienced with android. I'm just starting to learn.
But I'm sure we could team up to try and create a simple Quick Setting like this.
I already decompiled Rosie.apk and had a look inside, but didn't get anywhere.
Hope to hear from you guys.
Daan
DaanJordaan said:
Hi guys,
Would we be able to alter the Quick Setting menu in Sense 2.1 and create an extra setting for Auto Rotate?
I'm sure it would be possible.
If anyone has some idea on how to do it, please reply.
I'm not very experienced with android. I'm just starting to learn.
But I'm sure we could team up to try and create a simple Quick Setting like this.
I already decompiled Rosie.apk and had a look inside, but didn't get anywhere.
Hope to hear from you guys.
Daan
Click to expand...
Click to collapse
SystemUI.apk.....you'll need to do some xml & smali editing.
This is some weird stuff. It seems it is already been programmed in but not enabled in some way.
Code:
<com.android.systemui.statusbar.preference.QuickSettings
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent"><TextView
android:textAppearance="?android:textAppearanceLarge" android:textColor="#ffffffff"
android:gravity="center_vertical" android:id="@id/title_bar"
android:background="@drawable/status_bar_header_background"
android:paddingLeft="9.0sp" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:scaleType="fitXY"
android:text="@string/status_bar_quick_settings"/><ScrollView android:id="@id/scroll"
android:background="#ffffffff" android:fadingEdge="none" android:layout_width="fill_parent"
android:layout_height="fill_parent"><LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"><include
[B]android:id="@id/rotation" layout="@layout/status_bar_preference"/><include [/B]
android:id="@id/brightness" layout="@layout/status_bar_preference"/><include
android:id="@id/wifi" layout="@layout/status_bar_preference"/><include
android:id="@id/bluetooth" layout="@layout/status_bar_preference"/><include
android:id="@id/hotspot" layout="@layout/status_bar_preference"/><include
android:id="@id/gps" layout="@layout/status_bar_preference"/><include
android:id="@id/network" layout="@layout/status_bar_preference"/><include
android:id="@id/settings" layout="@layout/status_bar_preference"/></LinearLayout>
</ScrollView></com.android.systemui.statusbar.preference.QuickSettings>
I also changed:
Code:
.class public Lcom/android/systemui/statusbar/preference/QuickSettings;
.super Landroid/widget/LinearLayout;
.source "QuickSettings.java"
# static fields
.field private static final BRIGHTNESS:I = 0x4
.field private static final BT:I = 0x2
.field private static final GPS:I = 0x7
.field private static final HOTSPOT:I = 0x5
.field private static final ITEM_NUMBER:I = 0x8
.field private static final MOBILE_NETWORK:I = 0x3
[B].field private static final ROTATION:I = 0x0[/B]
.field private static final SETTINGS:I = 0x6
.field private static final WIFI:I = 0x1
........ this file goes on
to:
Code:
.class public Lcom/android/systemui/statusbar/preference/QuickSettings;
.super Landroid/widget/LinearLayout;
.source "QuickSettings.java"
# static fields
.field private static final BRIGHTNESS:I = 0x5
.field private static final BT:I = 0x3
.field private static final GPS:I = 0x8
.field private static final HOTSPOT:I = 0x6
.field private static final ITEM_NUMBER:I = 0x9
.field private static final MOBILE_NETWORK:I = 0x4
[B]
.field private static final ROTATION:I = 0x1[/B]
.field private static final SETTINGS:I = 0x7
.field private static final WIFI:I = 0x2
........ this file goes on
and tried:
Code:
.class public Lcom/android/systemui/statusbar/preference/QuickSettings;
.super Landroid/widget/LinearLayout;
.source "QuickSettings.java"
# static fields
.field private static final BRIGHTNESS:I = 0x4
.field private static final BT:I = 0x2
.field private static final GPS:I = 0x7
.field private static final [B]ROTATION[/B]:I = 0x5
.field private static final ITEM_NUMBER:I = 0x8
.field private static final MOBILE_NETWORK:I = 0x3
.field private static final [B]HOTSPOT[/B]:I = 0x0
.field private static final SETTINGS:I = 0x6
.field private static final WIFI:I = 0x1
........ this file goes on
Whatever I do the layout stays the same when I recompile.
Any Ideas?
DaanJordaan said:
This is some weird stuff. It seems it is already been programmed in but not enabled in some way.
Code:
<com.android.systemui.statusbar.preference.QuickSettings
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent"><TextView
android:textAppearance="?android:textAppearanceLarge" android:textColor="#ffffffff"
android:gravity="center_vertical" android:id="@id/title_bar"
android:background="@drawable/status_bar_header_background"
android:paddingLeft="9.0sp" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:scaleType="fitXY"
android:text="@string/status_bar_quick_settings"/><ScrollView android:id="@id/scroll"
android:background="#ffffffff" android:fadingEdge="none" android:layout_width="fill_parent"
android:layout_height="fill_parent"><LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"><include
[B]android:id="@id/rotation" layout="@layout/status_bar_preference"/><include [/B]
android:id="@id/brightness" layout="@layout/status_bar_preference"/><include
android:id="@id/wifi" layout="@layout/status_bar_preference"/><include
android:id="@id/bluetooth" layout="@layout/status_bar_preference"/><include
android:id="@id/hotspot" layout="@layout/status_bar_preference"/><include
android:id="@id/gps" layout="@layout/status_bar_preference"/><include
android:id="@id/network" layout="@layout/status_bar_preference"/><include
android:id="@id/settings" layout="@layout/status_bar_preference"/></LinearLayout>
</ScrollView></com.android.systemui.statusbar.preference.QuickSettings>
I also changed:
Code:
.class public Lcom/android/systemui/statusbar/preference/QuickSettings;
.super Landroid/widget/LinearLayout;
.source "QuickSettings.java"
# static fields
.field private static final BRIGHTNESS:I = 0x4
.field private static final BT:I = 0x2
.field private static final GPS:I = 0x7
.field private static final HOTSPOT:I = 0x5
.field private static final ITEM_NUMBER:I = 0x8
.field private static final MOBILE_NETWORK:I = 0x3
[B].field private static final ROTATION:I = 0x0[/B]
.field private static final SETTINGS:I = 0x6
.field private static final WIFI:I = 0x1
........ this file goes on
to:
Code:
.class public Lcom/android/systemui/statusbar/preference/QuickSettings;
.super Landroid/widget/LinearLayout;
.source "QuickSettings.java"
# static fields
.field private static final BRIGHTNESS:I = 0x5
.field private static final BT:I = 0x3
.field private static final GPS:I = 0x8
.field private static final HOTSPOT:I = 0x6
.field private static final ITEM_NUMBER:I = 0x9
.field private static final MOBILE_NETWORK:I = 0x4
[B]
.field private static final ROTATION:I = 0x1[/B]
.field private static final SETTINGS:I = 0x7
.field private static final WIFI:I = 0x2
........ this file goes on
and tried:
Code:
.class public Lcom/android/systemui/statusbar/preference/QuickSettings;
.super Landroid/widget/LinearLayout;
.source "QuickSettings.java"
# static fields
.field private static final BRIGHTNESS:I = 0x4
.field private static final BT:I = 0x2
.field private static final GPS:I = 0x7
.field private static final [B]ROTATION[/B]:I = 0x5
.field private static final ITEM_NUMBER:I = 0x8
.field private static final MOBILE_NETWORK:I = 0x3
.field private static final [B]HOTSPOT[/B]:I = 0x0
.field private static final SETTINGS:I = 0x6
.field private static final WIFI:I = 0x1
........ this file goes on
Whatever I do the layout stays the same when I recompile.
Any Ideas?
Click to expand...
Click to collapse
I would grab a SystemUI.apk that already has the mod, the stock apk they used as a base and compare the two. Should give you a better understanding.
TMartin said:
I would grab a SystemUI.apk that already has the mod, the stock apk they used as a base and compare the two. Should give you a better understanding.
Click to expand...
Click to collapse
and what more files we need ?
thanks
Sorry for the deadness... Didn't have time, to busy being on a holiday.
Anyhoo. I decompiled a Stock SytemUI.apk from HTC Sense 2.1.
This also has code in the SystemUI.apk for autorotate in the quick settings.
It seems like it has already been written but somehow it is not activated.
In the smali/com/android/systemui/statusbar/preference/ folder,
There are smali's for Brightness, BT, GPS, Hotspot, Rotation, Setting, Mobile Network, WiFi, Quick Settings and some more.
What do these files do?
Some of the names show up in the Quick Settings menu, but (i.e.) Brightness and Rotation do not.
How do we add these features, any ideas?
Cheers,
Daan
AARGH
Somebody has beat me to it
http://forum.xda-developers.com/showthread.php?t=1126333
Nice work
DaanJordaan said:
AARGH
Somebody has beat me to it
http://forum.xda-developers.com/showthread.php?t=1126333
Nice work
Click to expand...
Click to collapse
Can this be used on inc. s to?
Tried some of them works like a charm
lundberg512 said:
Can this be used on inc. s to?
Tried some of them works like a charm
Click to expand...
Click to collapse
Confirmed working?
Sent from my HTC Incredible S using Tapatalk
andrewxu said:
Confirmed working?
Sent from my HTC Incredible S using Tapatalk
Click to expand...
Click to collapse
Ive tried out a few of them working as they should. But seems hes updating to a new base...dont know if they are gonna work after that.
Will this work on HTC Hero (GSM) with this sense 2.1 rom HEROINE++??

getObjectField for nested objects?

Hiya,
So I have the hook I need, but I need to get a context. The object I'm in doesn't have a Context member, but it does have an ActivityManager object, and ActivityManager has a context.
The problem is that ActivityManager is an internal class, so I can't do this:
Code:
ActivityManager am = (ActivityManager) XposedHelpers.getObjectField(param.thisObject, "mAm");
Context context = (Context) XposedHelpers.getObjectField(am, "mContext");
I tried this, on a hunch:
Code:
Context context = (Context) XposedHelpers.getObjectField(param.thisObject, "mAm$mContext");
but that didn't work either.
Is there a way to get a field from a nested, internal object?
Thanks!
Ryan
Nevermind. Dumb question. Obviously, you do this:
Code:
Object am = (Object)XposedHelpers.getObjectField(param.thisObject, "mAm");
Context context = (Context) XposedHelpers.getObjectField(am, "mContext");

[Q] Mass change the object access Android Studio

I've been using Android Studio for a while, and it's one of the (if not the) most powerful IDE's I've used.
There is one thing I can't find though.
If you have a list like this:
Code:
private String username = null;
private String userAvatarURL = null;
private String bio = null;
private String birhtdate = null;
private String gender = null;
private String location = null;
private String twitter = null;
private String externalURL = null;
private String urlIFLprofile = null;
private String urlIFLwallpapers = null;
private List<Integer> wallpaperIdArray = null;
How do you change private to public without changing them one by one?
Thanks for the tip!
Tim
tim687 said:
I've been using Android Studio for a while, and it's one of the (if not the) most powerful IDE's I've used.
There is one thing I can't find though.
If you have a list like this:
Code:
private String username = null;
private String userAvatarURL = null;
private String bio = null;
private String birhtdate = null;
private String gender = null;
private String location = null;
private String twitter = null;
private String externalURL = null;
private String urlIFLprofile = null;
private String urlIFLwallpapers = null;
private List<Integer> wallpaperIdArray = null;
How do you change private to public without changing them one by one?
Thanks for the tip!
Tim
Click to expand...
Click to collapse
Code:
public String username = null;
public String userAvatarURL = null;
public String bio = null;
public String birhtdate = null;
public String gender = null;
public String location = null;
public String twitter = null;
public String externalURL = null;
public String urlIFLprofile = null;
public String urlIFLwallpapers = null;
public List<Integer> wallpaperIdArray = null;
Use Edit -> Find... -> Replace
Rember shortcut "Replace" .
Bye
cristaccio85 said:
Code:
public String username = null;
public String userAvatarURL = null;
public String bio = null;
public String birhtdate = null;
public String gender = null;
public String location = null;
public String twitter = null;
public String externalURL = null;
public String urlIFLprofile = null;
public String urlIFLwallpapers = null;
public List<Integer> wallpaperIdArray = null;
Use Edit -> Find... -> Replace
Rember shortcut "Replace" .
Bye
Click to expand...
Click to collapse
I knew that one, but what if your Object names contain public or private?
such as
Code:
private boolean visibleToPublic = false;

Help with db manipulation

Hello everyone, I have a problem, i made an app in android studio and i want to use an existing db which i already transferred in assets and project them into a list where every table will be a "category" and every record will be able to have its values manipulated i.e. "Name" "Value" [Item1,1] [Item2,2] Item1(value)+Item2(value)=3. I don't know if i'm being understandable...thanks anyway below i will attach my DatabaseHelper
Code:
import android.content.Context;
import android.database.sqlite.SQLiteAbortException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class DatabaseHelper extends SQLiteOpenHelper {
private static String DB_PATH = "";
private static String DB_NAME = "my.db";
private SQLiteDatabase myDataBase;
private final Context myContext;
public DatabaseHelper(Context context) {
super(context, DB_NAME, null,1);
this.myContext = context;
DB_PATH= myContext.getDatabasePath(DB_NAME).toString();
}
//Create an empty db to overwrite your own db on it
public void createDataBase() throws IOException{
boolean dbExist = checkDataBase();
if(dbExist){
//does nothing cause db already exists
}else{
//Overwrites db
this.getWritableDatabase();
try{
copyDataBase();
} catch(IOException e){
throw new Error("Error copying database");
}
}
}
// Check if db exists every time app opens
private boolean checkDataBase(){
SQLiteDatabase checkDB = null;
try{
String myPath = DB_PATH;
checkDB = SQLiteDatabase.openDatabase(myPath,null,SQLiteDatabase.OPEN_READONLY);
}catch (SQLiteException e){
//db doesn't exist yet
}
if (checkDB!=null){
checkDB.close();
}
return checkDB != null ? true : false;
}
//Copies your db from assets to the new db
private void copyDataBase() throws IOException{
//open your local db as input stream
InputStream myInput = myContext.getAssets().open(DB_NAME);
//Path to the empty db
String outFileName = DB_PATH;
//Open the empty db as the output stream
OutputStream myOutput = new FileOutputStream(outFileName);
//transfer bytes from I to O
byte[] buffer = new byte[1024];
int length;
while((length=myInput.read(buffer))>0){
myOutput.write(buffer,0,length);
}
//Close streams
myOutput.flush();
}
@Override
public void onCreate(SQLiteDatabase db) {
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}

Categories

Resources